summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-06-03 20:43:12 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-06-03 20:43:12 +0000
commit3931bdb788774e33dd623d6b9142ae69542c33aa (patch)
treec9fa7476a4a2bae4cdd7af18d4f87ea38d558c9e /test
parent404fa7257fae8e4252cd4d01017e97ab6062ab27 (diff)
downloadllvm-3931bdb788774e33dd623d6b9142ae69542c33aa.tar.gz
llvm-3931bdb788774e33dd623d6b9142ae69542c33aa.tar.bz2
llvm-3931bdb788774e33dd623d6b9142ae69542c33aa.tar.xz
SimplifyCFG: Do not transform PHI to select if doing so would be unsafe
PR16069 is an interesting case where an incoming value to a PHI is a trap value while also being a 'ConstantExpr'. We do not consider this case when performing the 'HoistThenElseCodeToIf' optimization. Instead, make our modifications more conservative if we detect that we cannot transform the PHI to a select. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183152 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/SimplifyCFG/PR16069.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/PR16069.ll b/test/Transforms/SimplifyCFG/PR16069.ll
new file mode 100644
index 0000000000..4e9f89660c
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/PR16069.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -simplifycfg -S | FileCheck %s
+
+; CHECK-NOT: select
+@b = extern_weak global i32
+define i32 @foo(i1 %y) {
+ br i1 %y, label %bb1, label %bb2
+bb1:
+ br label %bb3
+bb2:
+ br label %bb3
+bb3:
+ %cond.i = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb2 ]
+ ret i32 %cond.i
+}