]> granicus.if.org Git - llvm/commitdiff
[InstCombine] add test for possible zext-phi transform; NFC
authorSanjay Patel <spatel@rotateright.com>
Tue, 31 Jan 2017 17:43:00 +0000 (17:43 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 31 Jan 2017 17:43:00 +0000 (17:43 +0000)
The datalayout doesn't include i1, so we don't do a potential shrink and sink transform.

Example based on discussion here:
http://lists.llvm.org/pipermail/llvm-dev/2017-January/109631.html

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293656 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/zext-phi.ll [new file with mode: 0644]

diff --git a/test/Transforms/InstCombine/zext-phi.ll b/test/Transforms/InstCombine/zext-phi.ll
new file mode 100644 (file)
index 0000000..5d64b05
--- /dev/null
@@ -0,0 +1,29 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-n8:16:32:64"
+
+define i64 @sink_i1_casts(i1 %cond1, i1 %cond2) {
+; CHECK-LABEL: @sink_i1_casts(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[Z1:%.*]] = zext i1 %cond1 to i64
+; CHECK-NEXT:    br i1 %cond1, label %if, label %end
+; CHECK:       if:
+; CHECK-NEXT:    [[Z2:%.*]] = zext i1 %cond2 to i64
+; CHECK-NEXT:    br label %end
+; CHECK:       end:
+; CHECK-NEXT:    [[PHI:%.*]] = phi i64 [ [[Z1]], %entry ], [ [[Z2]], %if ]
+; CHECK-NEXT:    ret i64 [[PHI]]
+;
+entry:
+  %z1 = zext i1 %cond1 to i64
+  br i1 %cond1, label %if, label %end
+
+if:
+  %z2 = zext i1 %cond2 to i64
+  br label %end
+
+end:
+  %phi = phi i64 [ %z1, %entry ], [ %z2, %if ]
+  ret i64 %phi
+}
+