[LLVMdev] Shifts that use only 5 LSBs.

Eli Friedman eli.friedman at gmail.com
Tue Dec 16 18:27:44 PST 2008


On Tue, Dec 16, 2008 at 5:20 PM, Daniel M Gessel <gessel at apple.com> wrote:
> The problem here is that it looks like LLVM is introducing an expansion that
> assumes 32 bit shifts use more than 5 bits of the shift value.
> I created a simple test function:
> u64 mebbe_shift( u64 x, int test )
> {
> if( test )
> x <<= 2;
> return x;
> }
> I compile using clang, opt, and llc.
> I get something that, converted from my assembler to hasty psuedo-C:
> u64 mebbe_shift( u64 x, int test )
> {
> int amt = test ? 2 : 0;
> x.hi = x.hi << amt  |  x.lo >> (32 - amt);
> x.lo <<= amt;
>
> return x;
> }

Ouch, that's nasty... I just filed http://llvm.org/bugs/show_bug.cgi?id=3225.

-Eli



More information about the llvm-dev mailing list