[llvm-commits] [llvm] r75845 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/fold-bin-operand.ll
Eli Friedman
eli.friedman at gmail.com
Wed Jul 15 15:13:49 PDT 2009
Author: efriedma
Date: Wed Jul 15 17:13:34 2009
New Revision: 75845
URL: http://llvm.org/viewvc/llvm-project?rev=75845&view=rev
Log:
Don't restrict the set of instructions where we try to constant-fold the
operands; it's possible to end up with a constant-foldable operand to
most instructions, even those which can't trap.
Added:
llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=75845&r1=75844&r2=75845&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Jul 15 17:13:34 2009
@@ -13021,9 +13021,7 @@
continue;
}
- if (TD &&
- (I->getType()->getTypeID() == Type::VoidTyID ||
- I->isTrapping())) {
+ if (TD) {
// See if we can constant fold its operands.
for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(i))
Added: llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll?rev=75845&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll Wed Jul 15 17:13:34 2009
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep icmp
+
+define i1 @f(i1 %x) {
+ %b = and i1 %x, icmp eq (i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 2 to i8*))
+ ret i1 %b
+}
+
+; FIXME: This doesn't fold at the moment!
+; define i32 @f(i32 %x) {
+; %b = add i32 %x, zext (i1 icmp eq (i8* inttoptr (i32 1000000 to i8*), i8* inttoptr (i32 2000000 to i8*)) to i32)
+; ret i32 %b
+;}
+
More information about the llvm-commits
mailing list