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 missing TRULY_NOOP_TRUNCATION


On Jan  3, 2006, Adam Nemet <anemet@sonic.net> wrote:

>   long long 
>   g (long long a, long long b) 
>   { 
>     return ((a + b) << 32) >> 32; 
>   } 

> On MIPS64 we produce

>     j       $31
>     addu    $2,$5,$4

> for this function right now which is incorrect.  addu is a 32-bit
> operation and is unpredictable according to the MIPS64 reference
> manual if the operands are not sign-extended 32-bit values.

But if the left-hand left-shift operand is not a positive 32-bit
value, the left-shift overflows, which invokes undefined behavior, so
I say the generated code is perfectly standard-conforming and correct.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


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