diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f631d614573..1f80444632d 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -6582,7 +6582,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, // preferable because it allows the C<hasOneUse() && RHSV == 0 && - ICI.isEquality() && !Shift->isArithmeticShift()) { + ICI.isEquality() && !Shift->isArithmeticShift() && + !isa(Shift->getOperand(0))) { // Compute C << Y. Value *NS; if (Shift->getOpcode() == Instruction::LShr) { diff --git a/test/Transforms/InstCombine/2009-03-24-InfLoop.ll b/test/Transforms/InstCombine/2009-03-24-InfLoop.ll new file mode 100644 index 00000000000..6d5a7bf77d2 --- /dev/null +++ b/test/Transforms/InstCombine/2009-03-24-InfLoop.ll @@ -0,0 +1,9 @@ +; PR3874 +; RUN: llvm-as < %s | opt -instcombine | llvm-dis + define i1 @test(i32 %x) { + %A = lshr i32 3968, %x + %B = and i32 %A, 1 + %C = icmp eq i32 %B, 0 + ret i1 %C + } +