[llvm-commits] [llvm] r92419 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/or.ll
Nick Lewycky
nicholas at mxc.ca
Sat Jan 2 08:14:56 PST 2010
Author: nicholas
Date: Sat Jan 2 10:14:56 2010
New Revision: 92419
URL: http://llvm.org/viewvc/llvm-project?rev=92419&view=rev
Log:
Fix logic error in previous commit. The != case needs to become an or, not an
and.
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/or.ll
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=92419&r1=92418&r2=92419&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat Jan 2 10:14:56 2010
@@ -7324,9 +7324,13 @@
Constant::getNullValue(P->getType()));
Value *ICIQ = Builder->CreateICmp(ICI.getPredicate(), Q,
Constant::getNullValue(Q->getType()));
- Instruction *And = BinaryOperator::CreateAnd(ICIP, ICIQ, "");
- And->takeName(&ICI);
- return And;
+ Instruction *Op;
+ if (ICI.getPredicate() == ICmpInst::ICMP_EQ)
+ Op = BinaryOperator::CreateAnd(ICIP, ICIQ, "");
+ else
+ Op = BinaryOperator::CreateOr(ICIP, ICIQ, "");
+ Op->takeName(&ICI);
+ return Op;
}
break;
}
Modified: llvm/trunk/test/Transforms/InstCombine/or.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/or.ll?rev=92419&r1=92418&r2=92419&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/or.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/or.ll Sat Jan 2 10:14:56 2010
@@ -293,3 +293,17 @@
; CHECK: icmp ne i32 {{.*}}, 0
; CHECK: ret i1
}
+
+define i1 @test29(i32* %A, i32* %B) {
+ %C1 = ptrtoint i32* %A to i32
+ %C2 = ptrtoint i32* %B to i32
+ %D = or i32 %C1, %C2
+ %E = icmp ne i32 %D, 0
+ ret i1 %E
+; CHECK: @test29
+; CHECK: icmp ne i32* %A, null
+; CHECK: icmp ne i32* %B, null
+; CHECK: or i1
+; CHECK: ret i1
+}
+
More information about the llvm-commits
mailing list