summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/fold-phi.ll
diff options
context:
space:
mode:
authorMichael Ilseman <milseman@apple.com>2012-12-14 22:08:26 +0000
committerMichael Ilseman <milseman@apple.com>2012-12-14 22:08:26 +0000
commite2754dc887e285ffe1c2871f3da421b9aadf1d6d (patch)
treeb8640784c996337ebddb245b8c5ffcfc8ecff004 /llvm/test/Transforms/InstCombine/fold-phi.ll
parentacde77481ddc304fcca5c8f0f994b05e8575fec3 (diff)
downloadbcm5719-llvm-e2754dc887e285ffe1c2871f3da421b9aadf1d6d.tar.gz
bcm5719-llvm-e2754dc887e285ffe1c2871f3da421b9aadf1d6d.zip
Add back FoldOpIntoPhi optimizations with fix. Included test cases to help catch these errors and to test the presence of the optimization itself
llvm-svn: 170248
Diffstat (limited to 'llvm/test/Transforms/InstCombine/fold-phi.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/fold-phi.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fold-phi.ll b/llvm/test/Transforms/InstCombine/fold-phi.ll
new file mode 100644
index 00000000000..bd01d58aa58
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/fold-phi.ll
@@ -0,0 +1,39 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; CHECK: no_crash
+define float @no_crash(float %a) nounwind {
+entry:
+ br label %for.body
+
+for.body:
+ %sum.057 = phi float [ 0.000000e+00, %entry ], [ %add5, %bb0 ]
+ %add5 = fadd float %sum.057, %a ; PR14592
+ br i1 undef, label %bb0, label %end
+
+bb0:
+ br label %for.body
+
+end:
+ ret float %add5
+}
+
+; CHECK: fold_phi
+define float @fold_phi(float %a) nounwind {
+entry:
+ br label %for.body
+
+for.body:
+; CHECK: phi float
+; CHECK-NEXT: br i1 undef
+ %sum.057 = phi float [ 0.000000e+00, %entry ], [ %add5, %bb0 ]
+ %add5 = fadd float %sum.057, 1.0 ;; Should be moved to the latch!
+ br i1 undef, label %bb0, label %end
+
+; CHECK: bb0:
+bb0:
+; CHECK: fadd float
+ br label %for.body
+
+end:
+ ret float %add5
+}
OpenPOWER on IntegriCloud