[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 22:07:43 PDT 2010
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)));
In two operations, assuming the high bits in x are 0:
return (x ^ (1 << (B - 1))) - (1 << (B - 1));
>From Henry S. Warren, Jr., "Hacker's Delight".
More information about the llvm-commits
mailing list