[bugs] a gcc sign bug?

Jan Hubicka jh@suse.cz
Fri Jun 1 05:10:00 GMT 2001


> On Thu, May 31, 2001 at 12:53:51PM +0200, Jan Hubicka wrote:
> > > gcc will generate:
> > > 
> > > itsabug:
> > > .LFB1:
> > >         pushq   %rbp
> > > .LCFI0:
> > >         movq    %rsp, %rbp
> > > .LCFI1:
> > >         movq    kva_start(%rip), %rsi
> > >         subq    $2147483648, %rsi
> > > 		^^^^^^^^^^^
> > >         movl    $.LC0, %edi
> > >         movb    $0, %al
> > >         call    printf
> > >         popq    %rbp
> > > .LCFI2:
> > >         ret
> > the patch fixes it by converting subq to addq, in same way as we keep -128
> > as addq.
> > 
> > Thu May 31 12:52:38 CEST 2001  Jan Hubicka  <jh@suse.cz>
> > + 	  /* Avoid overflows.  */
> > + 	  && ((INTVAL (operands[2]) & ((1 << 31) - 1)))
> 
> I don't like this especially.  I'd rather we used INT_MIN
> and such, but this is a HOST_WIDE_INT.  
> 
> Would you create HOST_WIDE_INT_MIN and HOST_WIDE_INT_MAX
> defines in hwint.h and use that instead?
This is not overflow on host side, as HOST_WIDE_INT is 64bit,
it is overflow on target side, as x86_64 limit immediates to
32bit sign extended expressions.

Honza
> 
> 
> r~



More information about the Gcc-patches mailing list