[llvm-commits] [llvm] r121817 - in /llvm/trunk: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp test/Transforms/CorrelatedValuePropagation/crash.ll
Owen Anderson
resistor at mac.com
Tue Dec 14 16:55:35 PST 2010
Author: resistor
Date: Tue Dec 14 18:55:35 2010
New Revision: 121817
URL: http://llvm.org/viewvc/llvm-project?rev=121817&view=rev
Log:
Fix PR8790, another instance where unreachable code can cause instruction simplification to fail,
this case involve a select that simplifies to itself.
Modified:
llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
llvm/trunk/test/Transforms/CorrelatedValuePropagation/crash.ll
Modified: llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp?rev=121817&r1=121816&r2=121817&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp Tue Dec 14 18:55:35 2010
@@ -73,7 +73,12 @@
ConstantInt *CI = dyn_cast<ConstantInt>(C);
if (!CI) return false;
- S->replaceAllUsesWith(S->getOperand(CI->isOne() ? 1 : 2));
+ Value *ReplaceWith = S->getOperand(1);
+ Value *Other = S->getOperand(2);
+ if (!CI->isOne()) std::swap(ReplaceWith, Other);
+ if (ReplaceWith == S) ReplaceWith = UndefValue::get(S->getType());
+
+ S->replaceAllUsesWith(ReplaceWith);
S->eraseFromParent();
++NumSelects;
Modified: llvm/trunk/test/Transforms/CorrelatedValuePropagation/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CorrelatedValuePropagation/crash.ll?rev=121817&r1=121816&r2=121817&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CorrelatedValuePropagation/crash.ll (original)
+++ llvm/trunk/test/Transforms/CorrelatedValuePropagation/crash.ll Tue Dec 14 18:55:35 2010
@@ -18,3 +18,20 @@
for.end: ; preds = %for.cond.us, %for.cond.us.us, %entry
ret void
}
+
+; PR 8790
+define void @test2() nounwind ssp {
+entry:
+ br label %func_29.exit
+
+sdf.exit.i:
+ %l_44.1.mux.i = select i1 %tobool5.not.i, i8 %l_44.1.mux.i, i8 1
+ br label %srf.exit.i
+
+srf.exit.i:
+ %tobool5.not.i = icmp ne i8 undef, 0
+ br i1 %tobool5.not.i, label %sdf.exit.i, label %func_29.exit
+
+func_29.exit:
+ ret void
+}
More information about the llvm-commits
mailing list