This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is this a bug?
- To: Jay Monkman <jmonkman at frasca dot com>
- Subject: Re: Is this a bug?
- From: David Edelsohn <dje at watson dot ibm dot com>
- Date: Thu, 07 May 1998 23:31:50 -0400
- Cc: egcs at cygnus dot com
>>>>> Jay Monkman writes:
Jay> For the second add (temp=base + (unsigned long)0x8000;) the compiler
Jay> seems to want to do a
Jay> signed addition even though all the variables are unsigned.
Jay> temp=base + (unsigned long)0x8000;
Jay> // lwz 9,8(31) Load R9 with base
Jay> // addis 11,9,0x1 add 0x10000 and store in R11 - why is
Jay> this instruction here?
Jay> // addi 0,11,-32768 add 0x8000 and store in R0
Jay> // stw 0,12(31) store R0 as temp in stack frame
This is not a bug. If you actually look at the results produced
on PowerPC, they are correct. On PowerPC, additions by constants always
are signed, so GCC needs to compensate when performing an unsigned
addition by biasing the carry so that the result will be correct.
You also should mention that GCC only produces this sequence of
instructions for this example when not optimizing.
David
===============================================================================
David Edelsohn T.J. Watson Research Center
dje@watson.ibm.com P.O. Box 218
+1 914 945 4364 (TL 862) Yorktown Heights, NY 10598