[llvm-commits] [llvm] r91624 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast_ptr.ll
Eli Friedman
eli.friedman at gmail.com
Thu Dec 17 13:27:47 PST 2009
Author: efriedma
Date: Thu Dec 17 15:27:47 2009
New Revision: 91624
URL: http://llvm.org/viewvc/llvm-project?rev=91624&view=rev
Log:
Make the ptrtoint comparison simplification work if one side is a global.
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=91624&r1=91623&r2=91624&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Dec 17 15:27:47 2009
@@ -6452,7 +6452,7 @@
// if (X) ...
// For generality, we handle any zero-extension of any operand comparison
// with a constant or another cast from the same type.
- if (isa<ConstantInt>(Op1) || isa<CastInst>(Op1))
+ if (isa<Constant>(Op1) || isa<CastInst>(Op1))
if (Instruction *R = visitICmpInstWithCastAndCast(I))
return R;
}
Modified: llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll?rev=91624&r1=91623&r2=91624&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll Thu Dec 17 15:27:47 2009
@@ -27,3 +27,12 @@
ret i1 %r
}
+; These casts should also be folded away.
+; CHECK: @test3
+; CHECK: icmp eq i8* %a, @global
+ at global = global i8 0
+define i1 @test3(i8* %a) {
+ %tmpa = ptrtoint i8* %a to i32
+ %r = icmp eq i32 %tmpa, ptrtoint (i8* @global to i32)
+ ret i1 %r
+}
More information about the llvm-commits
mailing list