This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch to fix constant math - first small patch - patch ping for the next stage 1


On Wed, Feb 27, 2013 at 1:22 AM, Kenneth Zadeck
<zadeck@naturalbridge.com> wrote:
> Here is the first of my wide int patches with joseph's comments and the
> patch rot removed.
>
> I would like to get these pre approved for the next stage 1.

+      int shift = HOST_BITS_PER_WIDE_INT - (prec &
(HOST_BITS_PER_WIDE_INT - 1));

I think this should gcc_checking_assert that prec is not out of range
(any reason why prec is signed int and not unsigned int?) rather than
ignore bits in prec.

+static inline HOST_WIDE_INT
+zext_hwi (HOST_WIDE_INT src, int prec)
+{
+  if (prec == HOST_BITS_PER_WIDE_INT)
+    return src;
+  else
+    return src & (((HOST_WIDE_INT)1
+                  << (prec & (HOST_BITS_PER_WIDE_INT - 1))) - 1);
+}

likewise.  Also I'm not sure I agree about the signedness of the result / src.
zext_hwi (-1, HOST_BITS_PER_WIDE_INT) < 0 is true which is odd.

The patch misses context of uses, so I'm not sure what the above functions
are intended to do.

Richard.

> On 10/05/2012 08:14 PM, Joseph S. Myers wrote:
>>
>> On Fri, 5 Oct 2012, Kenneth Zadeck wrote:
>>
>>> +# define HOST_HALF_WIDE_INT_PRINT "h"
>>
>> This may cause problems on hosts not supporting %hd (MinGW?), and there's
>> no real need for using "h" here given the promotion of short to int; you
>> can just use "" (rather than e.g. needing special handling in xm-mingw32.h
>> like is done for HOST_LONG_LONG_FORMAT).
>>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]