summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/phi-select-constant.ll
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2017-06-16 21:08:37 +0000
committerAnna Thomas <anna@azul.com>2017-06-16 21:08:37 +0000
commit6bc14c65ad3e237cfb034ed569358f40e3b45318 (patch)
tree2d4e726863da036e6b5927ffdd9f2728727ca007 /llvm/test/Transforms/InstCombine/phi-select-constant.ll
parent5a308f24c3e722dc40307c5ad68eff63b90a5d6b (diff)
downloadbcm5719-llvm-6bc14c65ad3e237cfb034ed569358f40e3b45318.tar.gz
bcm5719-llvm-6bc14c65ad3e237cfb034ed569358f40e3b45318.zip
[InstCombine] Set correct insertion point for selects generated while folding phis
Summary: When we fold vector constants that are operands of phi's that feed into select, we need to set the correct insertion point for the *new* selects that get generated. The correct insertion point is the incoming block for the phi. Such cases can occur with patch r298845, which fixed folding of vector constants, but the new selects could be inserted incorrectly (as the added test case shows). Reviewers: majnemer, spatel, sanjoy Reviewed by: spatel Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34162 llvm-svn: 305591
Diffstat (limited to 'llvm/test/Transforms/InstCombine/phi-select-constant.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/phi-select-constant.ll29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/phi-select-constant.ll b/llvm/test/Transforms/InstCombine/phi-select-constant.ll
index 272594d7f4f..83c4efb2a78 100644
--- a/llvm/test/Transforms/InstCombine/phi-select-constant.ll
+++ b/llvm/test/Transforms/InstCombine/phi-select-constant.ll
@@ -55,3 +55,32 @@ final:
%sel = select <4 x i1> %phinode, <4 x i64> zeroinitializer, <4 x i64> <i64 124, i64 125, i64 126, i64 127>
ret <4 x i64> %sel
}
+
+; Test PR33364
+; Insert the generated select into the same block as the incoming phi value.
+; phi has constant vectors along with a single non-constant vector as operands.
+define <2 x i8> @vec3(i1 %cond1, i1 %cond2, <2 x i1> %x, <2 x i8> %y, <2 x i8> %z) {
+; CHECK-LABEL: @vec3
+; CHECK-LABEL: entry:
+; CHECK-NEXT: [[PHITMP1:%.*]] = shufflevector <2 x i8> %y, <2 x i8> %z, <2 x i32> <i32 2, i32 1>
+entry:
+ br i1 %cond1, label %if1, label %else
+
+; CHECK-LABEL: if1:
+; CHECK-NEXT: [[PHITMP2:%.*]] = shufflevector <2 x i8> %y, <2 x i8> %z, <2 x i32> <i32 0, i32 3>
+if1:
+ br i1 %cond2, label %if2, label %else
+
+; CHECK-LABEL: if2:
+; CHECK-NEXT: [[PHITMP3:%.*]] = select <2 x i1> %x, <2 x i8> %y, <2 x i8> %z
+if2:
+ br label %else
+
+; CHECK-LABEL: else:
+; CHECK-NEXT: [[PHITMP4:%.*]] = phi <2 x i8> [ [[PHITMP3]], %if2 ], [ [[PHITMP1]], %entry ], [ [[PHITMP2]], %if1 ]
+; CHECK-NEXT: ret <2 x i8> [[PHITMP4]]
+else:
+ %phi = phi <2 x i1> [ %x, %if2 ], [ <i1 0, i1 1>, %entry ], [ <i1 1, i1 0>, %if1 ]
+ %sel = select <2 x i1> %phi, <2 x i8> %y, <2 x i8> %z
+ ret <2 x i8> %sel
+}
OpenPOWER on IntegriCloud