[llvm-commits] [llvm] r100233 - in /llvm/trunk: ./ include/llvm/Support/ lib/Target/ARM/ lib/Target/ARM/Disassembler/ test/MC/Disassembler/ utils/TableGen/

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Apr 4 21:03:00 PDT 2010


On Sun, 2010-04-04 at 20:54 -0700, Chris Lattner wrote:
> On Apr 4, 2010, at 8:48 PM, Jakob Stoklund Olesen wrote:
> 
> > On Sun, 2010-04-04 at 20:32 -0700, Chris Lattner wrote:
> >> On Apr 4, 2010, at 6:59 PM, Jakob Stoklund Olesen wrote:
> >> 
> >>> 
> >>> On Apr 4, 2010, at 6:48 PM, Johnny Chen wrote:
> >>> 
> >>>> Hi Jakob,
> >>>> 
> >>>> Thanks.  You're welcome to modify the MathExtras.h stuff.
> >>>> Right now, arm disassembler is the only client of SignExtend32<B>(int32_t x).
> >>>> I originally use a bit-field hack but Chris thinks it is non-portable.
> >>> 
> >>> How about this?
> >>> 
> >>> return x | -(x & (1 << (B - 1)));
> >> 
> >> Shift left + shift right is more easily recognized by the code generator as a sext.
> > 
> > Sure, but if we're not building with -fwrapv, it overflows the int and
> > causes undefined behaviour.
> 
> Huh?  In what case?

If you left-shift a positive number until it goes negative, that's an
overflow. At least that's how I understand it.






More information about the llvm-commits mailing list