PATCH: add new transformations in cse
Dale Johannesen
dalej@apple.com
Tue Dec 18 17:05:00 GMT 2001
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.
More information about the Gcc-patches
mailing list