summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2017-10-31 05:16:46 +0000
committerPhilip Reames <listmail@philipreames.com>2017-10-31 05:16:46 +0000
commit59bf1e0548460364e96f168bef5fcd66a98d54cb (patch)
tree755f7c3b12fadce6442f28506c9344f65ae01c6a /llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
parent488ec975bb418cc3fd230a9acdfdb1effc61670e (diff)
downloadbcm5719-llvm-59bf1e0548460364e96f168bef5fcd66a98d54cb.tar.gz
bcm5719-llvm-59bf1e0548460364e96f168bef5fcd66a98d54cb.zip
[IndVarSimplify] Simplify code using preheader assumption
As noted in the nice block comment, the previous code didn't actually handle multi-entry loops correctly, it just assumed SCEV didn't analyze such loops. Given SCEV has comments to the contrary, that seems a bit suspect. More importantly, the pass actually requires loopsimplify form which ensures a loop-preheader is available. Remove the excessive generaility and shorten the code greatly. Note that we do successfully analyze many multi-entry loops, but we do so by converting them to single entry loops. See the added test case. llvm-svn: 316976
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll')
-rw-r--r--llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll b/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
index eee321da239..1c8eb93869a 100644
--- a/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
+++ b/llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
@@ -273,6 +273,28 @@ for.end: ; preds = %if.end, %entry
ret void
}
+; check to handle loops without preheaders, but invariant operands
+; (we handle this today by inserting a preheader)
+define void @test9(i1 %cnd, i64 %start) {
+; CHECK-LABEL: @test9
+; CHECK-LABEL: loop.preheader:
+entry:
+ br i1 %cnd, label %entry1, label %entry2
+entry1:
+ br label %loop
+entry2:
+ br label %loop
+loop:
+ %indvars.iv = phi i64 [ %start, %entry1 ],[ %start, %entry2 ], [ %indvars.iv.next, %loop ]
+ %indvars.iv.next = add nsw i64 %indvars.iv, 1
+; CHECK: %cmp1 = icmp slt i64 %start, -1
+ %cmp1 = icmp slt i64 %indvars.iv, -1
+ br i1 %cmp1, label %for.end, label %loop
+
+for.end: ; preds = %if.end, %entry
+ ret void
+}
+
!1 = !{i64 -1, i64 100}
OpenPOWER on IntegriCloud