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: add new transformations in cse



On Tuesday, December 18, 2001, at 04:44 PM, Geert Bosch wrote:

>
> On Tuesday, December 18, 2001, at 05:36 , Dale Johannesen wrote:
>
>> +     case PLUS:
>> +       /* If we have (PLUS X Y), see if X is known to be (NEG Z).
>> +        If so, this simplifies to (MINUS Y Z).  */
>> +
>
> Forgive me if this code only deals with unsigned types and my comment is
> way off, but for signed types I don't think this holds. If Z==-32768,
> then NEG Z would be zero and the operation yields (PLUS 0 Y), but with the
> simplification it would ield (MINUS Y -32768). Maybe an extra comment 
> about
> the kind of values this handles would be nice, since I can't easily derive
> this from the context in cse.c.

I believe this applies to all types; the questionable ones are floating 
point,
as I said in the original patch (nobody has responded to that part yet).
I'm not sure I understand your example.  If sizeof(int)==2, then -(-32768)
  == -32768
and the result comes out correct.  I think the same is true of shorts when
sizeof(int)==4.  Twos complement has clean wraparound.


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