summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp4
-rw-r--r--llvm/test/Transforms/Reassociate/reassociate-deadinst.ll16
2 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 1ec7fcea109..ac0d7b8f1dd 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -2198,8 +2198,10 @@ PreservedAnalyses ReassociatePass::run(Function &F, FunctionAnalysisManager &) {
// trivially dead instructions have been removed.
while (!ToRedo.empty()) {
Instruction *I = ToRedo.pop_back_val();
- if (isInstructionTriviallyDead(I))
+ if (isInstructionTriviallyDead(I)) {
RecursivelyEraseDeadInsts(I, ToRedo);
+ MadeChange = true;
+ }
}
// Now that we have removed dead instructions, we can reoptimize the
diff --git a/llvm/test/Transforms/Reassociate/reassociate-deadinst.ll b/llvm/test/Transforms/Reassociate/reassociate-deadinst.ll
new file mode 100644
index 00000000000..6a12c4723f2
--- /dev/null
+++ b/llvm/test/Transforms/Reassociate/reassociate-deadinst.ll
@@ -0,0 +1,16 @@
+; RUN: opt -inline -functionattrs -reassociate %s -S | FileCheck %s
+
+; CHECK-NOT: func1
+; CHECK-LABEL: main
+; CHECK-NEXT: ret void
+
+define internal i16 @func1() noinline #0 {
+ ret i16 0
+}
+
+define void @main(i16 %argc, i16** %argv) #0 {
+ %_tmp0 = call i16 @func1()
+ %_tmp2 = zext i16 %_tmp0 to i32
+ ret void
+}
+attributes #0 = { minsize nounwind optsize }
OpenPOWER on IntegriCloud