summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/StructurizeCFG
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2018-10-15 22:37:46 +0000
committerNicolai Haehnle <nhaehnle@gmail.com>2018-10-15 22:37:46 +0000
commit6d92ca61f918456726b67d124499cbf0595ba335 (patch)
treeb10b57ae5392d58476b8f45df63f29c85c88d431 /llvm/test/Transforms/StructurizeCFG
parent31073637a7e6fa39b66260010939d2de50b8268e (diff)
downloadbcm5719-llvm-6d92ca61f918456726b67d124499cbf0595ba335.tar.gz
bcm5719-llvm-6d92ca61f918456726b67d124499cbf0595ba335.zip
StructurizeCFG,AMDGPU: Test case of a redundant phi and codegen consequences
Change-Id: I9681f9e41ca30f82576f3d1f965c3a550a34b171 llvm-svn: 344569
Diffstat (limited to 'llvm/test/Transforms/StructurizeCFG')
-rw-r--r--llvm/test/Transforms/StructurizeCFG/loop-continue-phi.ll45
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/test/Transforms/StructurizeCFG/loop-continue-phi.ll b/llvm/test/Transforms/StructurizeCFG/loop-continue-phi.ll
new file mode 100644
index 00000000000..7e1c0b9413f
--- /dev/null
+++ b/llvm/test/Transforms/StructurizeCFG/loop-continue-phi.ll
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -o - -structurizecfg < %s | FileCheck %s
+
+;
+; TODO: eliminate redundant phis for the loop counter
+;
+define void @test1() {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: Flow:
+; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[CTR_NEXT:%.*]], [[LOOP_B:%.*]] ], [ [[CTR_NEXT]], [[LOOP_A:%.*]] ]
+; CHECK-NEXT: br label [[FLOW1:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[CTR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TMP1:%.*]], [[FLOW1]] ]
+; CHECK-NEXT: [[CTR_NEXT]] = add i32 [[CTR]], 1
+; CHECK-NEXT: br i1 undef, label [[LOOP_A]], label [[FLOW1]]
+; CHECK: loop.a:
+; CHECK-NEXT: br i1 undef, label [[LOOP_B]], label [[FLOW:%.*]]
+; CHECK: loop.b:
+; CHECK-NEXT: br label [[FLOW]]
+; CHECK: Flow1:
+; CHECK-NEXT: [[TMP1]] = phi i32 [ [[TMP0]], [[FLOW]] ], [ undef, [[LOOP]] ]
+; CHECK-NEXT: [[TMP2:%.*]] = phi i1 [ false, [[FLOW]] ], [ true, [[LOOP]] ]
+; CHECK-NEXT: br i1 [[TMP2]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %loop
+
+loop:
+ %ctr = phi i32 [ 0, %entry ], [ %ctr.next, %loop.a ], [ %ctr.next, %loop.b ]
+ %ctr.next = add i32 %ctr, 1
+ br i1 undef, label %exit, label %loop.a
+
+loop.a:
+ br i1 undef, label %loop, label %loop.b
+
+loop.b:
+ br label %loop
+
+exit:
+ ret void
+}
OpenPOWER on IntegriCloud