[llvm-commits] [llvm] r53276 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-07-08-ShiftOneAndOne.ll

Chris Lattner clattner at apple.com
Tue Jul 8 23:34:10 PDT 2008


On Jul 8, 2008, at 10:20 PM, Nick Lewycky wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=53276&view=rev
> Log:
> Fold ((1 << a) & 1) to (a == 0).

Nice.

> +
> +      case Instruction::Shl:
> +      case Instruction::LShr:
> +        // (1 << x) & 1 --> zext(x == 0)
> +        // (1 >> x) & 1 --> zext(x == 0)
> +        if (AndRHSMask.getLimitedValue() == 1 &&

I'd suggest "if (AndRHSMask == 1 && ..."

which should do the right thing.

Nice catch,

-Chris



More information about the llvm-commits mailing list