summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/IndVarSimplify/dont-recompute.ll
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2018-11-01 06:47:01 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2018-11-01 06:47:01 +0000
commit3d347bf545d51156b3c1bf6ed93100369568a550 (patch)
tree6345424779cffca969eda3fe6f73518cd2a26fc8 /llvm/test/Transforms/IndVarSimplify/dont-recompute.ll
parente0a2613aeaae93bf75ccc6c616fec3c45147a3df (diff)
downloadbcm5719-llvm-3d347bf545d51156b3c1bf6ed93100369568a550.tar.gz
bcm5719-llvm-3d347bf545d51156b3c1bf6ed93100369568a550.zip
[IndVars] Smart hard uses detection
When rewriting loop exit values, IndVars considers this transform not profitable if the loop instruction has a loop user which it believes cannot be optimized away. In current implementation only calls that immediately use the instruction are considered as such. This patch extends the definition of "hard" users to any side-effecting instructions (which usually cannot be optimized away from the loop) and also allows handling of not just immediate users, but use chains. Differentlai Revision: https://reviews.llvm.org/D51584 Reviewed By: etherzhhb llvm-svn: 345814
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify/dont-recompute.ll')
-rw-r--r--llvm/test/Transforms/IndVarSimplify/dont-recompute.ll51
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/dont-recompute.ll b/llvm/test/Transforms/IndVarSimplify/dont-recompute.ll
index c87cd6596c6..22087710a9c 100644
--- a/llvm/test/Transforms/IndVarSimplify/dont-recompute.ll
+++ b/llvm/test/Transforms/IndVarSimplify/dont-recompute.ll
@@ -123,3 +123,54 @@ for.end: ; preds = %for.body
tail call void @func(i32 %soft_use)
ret void
}
+
+; CHECK-LABEL: @test5(
+define void @test5(i32 %m) nounwind uwtable {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ %a.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
+ %add = add i32 %a.05, %m
+ %soft_use = add i32 %add, 123
+; CHECK: tail call void @func(i32 %soft_use)
+ tail call void @func(i32 %soft_use)
+ %inc = add nsw i32 %i.06, 1
+ %exitcond = icmp eq i32 %inc, 186
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+; CHECK: for.end:
+; CHECK-NOT: mul i32 %m, 186
+; CHECK:%add.lcssa = phi i32 [ %add, %for.body ]
+; CHECK-NEXT: tail call void @func(i32 %add.lcssa)
+ tail call void @func(i32 %add)
+ ret void
+}
+
+; CHECK-LABEL: @test6(
+define void @test6(i32 %m, i32* %p) nounwind uwtable {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ %a.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
+ %add = add i32 %a.05, %m
+ %soft_use = add i32 %add, 123
+; CHECK: store i32 %soft_use, i32* %pidx
+ %pidx = getelementptr i32, i32* %p, i32 %add
+ store i32 %soft_use, i32* %pidx
+ %inc = add nsw i32 %i.06, 1
+ %exitcond = icmp eq i32 %inc, 186
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+; CHECK: for.end:
+; CHECK-NOT: mul i32 %m, 186
+; CHECK:%add.lcssa = phi i32 [ %add, %for.body ]
+; CHECK-NEXT: tail call void @func(i32 %add.lcssa)
+ tail call void @func(i32 %add)
+ ret void
+}
OpenPOWER on IntegriCloud