From e8e4921967994726e2e64c9906e23fec52f00cf7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 25 Mar 2009 00:28:58 +0000 Subject: [PATCH] Fix PR3874 by restoring a condition I removed, but making it more precise than it used to be. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67662 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 3 ++- test/Transforms/InstCombine/2009-03-24-InfLoop.ll | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/InstCombine/2009-03-24-InfLoop.ll 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 + } + -- 2.34.1