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: trivial rs6000 fix


Stuart Hastings <stuart@apple.com> writes:
> -#define SMALL_INT(X) ((unsigned) (INTVAL (X) + 0x8000) < 0x10000)
> +#define SMALL_INT(X) ((unsigned HOST_WIDE_INT) (INTVAL (X) + 0x8000) < 0x10000)

One thing that's been bugging me for a while: now that gcc's optimisers
are being more aggressive in using the undefinedness of signed overflow,
should we be more careful about adding signed HOST_WIDE_INTs like this?

Not a comment about this patch specifically -- the same construct is
used all over the place, and it's unlikely that a simple test like this
would get screwed up.  I just thought I'd point it out because (a) I think
we need a new function or macro to make these kinds of test and (b) the
"right thing" is actually two characters shorter:

#define SMALL_INT(X) ((unsigned HOST_WIDE_INT) INTVAL (X) + 0x8000 < 0x10000)

Richard


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