[llvm-commits] [llvm] r108114 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll
Chris Lattner
sabre at nondot.org
Sun Jul 11 17:47:34 PDT 2010
Author: lattner
Date: Sun Jul 11 19:47:34 2010
New Revision: 108114
URL: http://llvm.org/viewvc/llvm-project?rev=108114&view=rev
Log:
if jump threading is able to infer interesting values on both
the LHS and RHS of an and/or instruction, don't multiply add
known predecessor values. This fixes the crash on testcase
from PR7498
Modified:
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
llvm/trunk/test/Transforms/JumpThreading/crash.ll
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=108114&r1=108113&r2=108114&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Jul 11 19:47:34 2010
@@ -346,8 +346,19 @@
}
for (unsigned i = 0, e = RHSVals.size(); i != e; ++i)
if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0) {
- Result.push_back(RHSVals[i]);
- Result.back().first = InterestingVal;
+ // If we already inferred a value for this block on the LHS, don't
+ // re-add it.
+ bool HasValue = false;
+ for (unsigned r = 0, e = Result.size(); r != e; ++r)
+ if (Result[r].second == RHSVals[i].second) {
+ HasValue = true;
+ break;
+ }
+
+ if (!HasValue) {
+ Result.push_back(RHSVals[i]);
+ Result.back().first = InterestingVal;
+ }
}
return !Result.empty();
}
Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=108114&r1=108113&r2=108114&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original)
+++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Sun Jul 11 19:47:34 2010
@@ -363,3 +363,27 @@
ret i32 1422
}
+
+; PR7498
+define void @test14() nounwind {
+entry:
+ %cmp33 = icmp slt i8 undef, 0 ; <i1> [#uses=1]
+ %tobool = icmp eq i8 undef, 0 ; <i1> [#uses=1]
+ br i1 %tobool, label %land.end69, label %land.rhs
+
+land.rhs: ; preds = %entry
+ br label %land.end69
+
+land.end69: ; preds = %land.rhs, %entry
+ %0 = phi i1 [ undef, %land.rhs ], [ true, %entry ] ; <i1> [#uses=1]
+ %cmp71 = or i1 true, %0 ; <i1> [#uses=1]
+ %cmp73 = xor i1 %cmp33, %cmp71 ; <i1> [#uses=1]
+ br i1 %cmp73, label %if.then, label %if.end
+
+if.then: ; preds = %land.end69
+ ret void
+
+if.end: ; preds = %land.end69
+ ret void
+}
+
More information about the llvm-commits
mailing list