[llvm-branch-commits] [llvm-branch] r168974 - in /llvm/branches/release_32: ./ lib/Analysis/ScalarEvolution.cpp test/Transforms/IndVarSimplify/eliminate-comparison.ll
Pawel Wodnicki
pawel at 32bitmicro.com
Thu Nov 29 19:38:58 PST 2012
Author: pawel
Date: Thu Nov 29 21:38:58 2012
New Revision: 168974
URL: http://llvm.org/viewvc/llvm-project?rev=168974&view=rev
Log:
Merging r168921: into the 3.2 release branch.
Follow up to 168711: It's safe to base this analysis on the found compare, just return the value for the right predicate.
Thanks to Andy for catching this.
Modified:
llvm/branches/release_32/ (props changed)
llvm/branches/release_32/lib/Analysis/ScalarEvolution.cpp
llvm/branches/release_32/test/Transforms/IndVarSimplify/eliminate-comparison.ll
Propchange: llvm/branches/release_32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 29 21:38:58 2012
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,167718-167719,167731,167737,167743,167750,167784,167811,167817,167855,167860-167864,167875,167912,167942,167948,167966,168001,168035,168181,168186,168189,168196-168198,168227,168280,168291,168316,168319-168320,168346,168352,168354,168361,168364,168512,168622,168711,168765,168799,168837
+/llvm/trunk:155241,167718-167719,167731,167737,167743,167750,167784,167811,167817,167855,167860-167864,167875,167912,167942,167948,167966,168001,168035,168181,168186,168189,168196-168198,168227,168280,168291,168316,168319-168320,168346,168352,168354,168361,168364,168512,168622,168711,168765,168799,168837,168921
Modified: llvm/branches/release_32/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_32/lib/Analysis/ScalarEvolution.cpp?rev=168974&r1=168973&r2=168974&view=diff
==============================================================================
--- llvm/branches/release_32/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/branches/release_32/lib/Analysis/ScalarEvolution.cpp Thu Nov 29 21:38:58 2012
@@ -6149,10 +6149,9 @@
if (SimplifyICmpOperands(Pred, LHS, RHS))
if (LHS == RHS)
return CmpInst::isTrueWhenEqual(Pred);
-
- // Canonicalize the found cond too. We can't conclude a result from the
- // simplified values.
- SimplifyICmpOperands(FoundPred, FoundLHS, FoundRHS);
+ if (SimplifyICmpOperands(FoundPred, FoundLHS, FoundRHS))
+ if (FoundLHS == FoundRHS)
+ return CmpInst::isFalseWhenEqual(FoundPred);
// Check to see if we can make the LHS or RHS match.
if (LHS == FoundRHS || RHS == FoundLHS) {
Modified: llvm/branches/release_32/test/Transforms/IndVarSimplify/eliminate-comparison.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_32/test/Transforms/IndVarSimplify/eliminate-comparison.ll?rev=168974&r1=168973&r2=168974&view=diff
==============================================================================
--- llvm/branches/release_32/test/Transforms/IndVarSimplify/eliminate-comparison.ll (original)
+++ llvm/branches/release_32/test/Transforms/IndVarSimplify/eliminate-comparison.ll Thu Nov 29 21:38:58 2012
@@ -160,3 +160,52 @@
}
declare void @llvm.trap() noreturn nounwind
+
+; In this case the second loop only has a single iteration, fold the header away
+; CHECK: @func_12
+; CHECK: %tmp5 = icmp slt i32 %__key6.0, 10
+; CHECK: br i1 true, label %noassert68, label %unrolledend
+define i32 @func_12() nounwind uwtable {
+entry:
+ br label %forcond
+
+forcond: ; preds = %noassert, %entry
+ %__key6.0 = phi i32 [ 2, %entry ], [ %tmp37, %noassert ]
+ %tmp5 = icmp slt i32 %__key6.0, 10
+ br i1 %tmp5, label %noassert, label %forcond38.preheader
+
+forcond38.preheader: ; preds = %forcond
+ br label %forcond38
+
+noassert: ; preds = %forbody
+ %tmp13 = sdiv i32 -32768, %__key6.0
+ %tmp2936 = shl i32 %tmp13, 24
+ %sext23 = shl i32 %tmp13, 24
+ %tmp32 = icmp eq i32 %tmp2936, %sext23
+ %tmp37 = add i32 %__key6.0, 1
+ br i1 %tmp32, label %forcond, label %assert33
+
+assert33: ; preds = %noassert
+ tail call void @llvm.trap()
+ unreachable
+
+forcond38: ; preds = %noassert68, %forcond38.preheader
+ %__key8.0 = phi i32 [ %tmp81, %noassert68 ], [ 2, %forcond38.preheader ]
+ %tmp46 = icmp slt i32 %__key8.0, 10
+ br i1 %tmp46, label %noassert68, label %unrolledend
+
+noassert68: ; preds = %forbody39
+ %tmp57 = sdiv i32 -32768, %__key8.0
+ %sext34 = shl i32 %tmp57, 16
+ %sext21 = shl i32 %tmp57, 16
+ %tmp76 = icmp ne i32 %sext34, %sext21
+ %tmp81 = add i32 %__key8.0, 1
+ br i1 %tmp76, label %forcond38, label %assert77
+
+assert77: ; preds = %noassert68
+ tail call void @llvm.trap()
+ unreachable
+
+unrolledend: ; preds = %forcond38
+ ret i32 0
+}
More information about the llvm-branch-commits
mailing list