summaryrefslogtreecommitdiff
path: root/test/Transforms/IndVarSimplify/exit_value_test2.ll
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-08-20 21:02:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-08-20 21:02:43 +0000
commit15c5c77fa04cd97e1057e8a585f669fc49da0d92 (patch)
tree9047e00a30ccb7b81dbe7227c8c883cbafb5d2dd /test/Transforms/IndVarSimplify/exit_value_test2.ll
parent4e20bb0468b8d0db13287e666b482eb93689be99 (diff)
Notes
Diffstat (limited to 'test/Transforms/IndVarSimplify/exit_value_test2.ll')
-rw-r--r--test/Transforms/IndVarSimplify/exit_value_test2.ll28
1 files changed, 25 insertions, 3 deletions
diff --git a/test/Transforms/IndVarSimplify/exit_value_test2.ll b/test/Transforms/IndVarSimplify/exit_value_test2.ll
index ee641667506c..7b6e91a742b2 100644
--- a/test/Transforms/IndVarSimplify/exit_value_test2.ll
+++ b/test/Transforms/IndVarSimplify/exit_value_test2.ll
@@ -3,15 +3,14 @@
; Check IndVarSimplify should not replace exit value because or else
; udiv will be introduced by expand and the cost will be high.
-;
-; CHECK-LABEL: @_Z3fooPKcjj(
-; CHECK-NOT: udiv
declare void @_Z3mixRjj(i32* dereferenceable(4), i32)
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
define i32 @_Z3fooPKcjj(i8* nocapture readonly %s, i32 %len, i32 %c) {
+; CHECK-LABEL: @_Z3fooPKcjj(
+; CHECK-NOT: udiv
entry:
%a = alloca i32, align 4
%tmp = bitcast i32* %a to i8*
@@ -50,3 +49,26 @@ while.end: ; preds = %while.cond.while.en
call void @llvm.lifetime.end.p0i8(i64 4, i8* %tmp)
ret i32 %tmp4
}
+
+define i32 @zero_backedge_count_test(i32 %unknown_init, i32* %unknown_mem) {
+; CHECK-LABEL: @zero_backedge_count_test(
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i32 [ 0, %entry], [ %iv.inc, %loop ]
+ %unknown_phi = phi i32 [ %unknown_init, %entry ], [ %unknown_next, %loop ]
+ %iv.inc = add i32 %iv, 1
+ %be_taken = icmp ne i32 %iv.inc, 1
+ %unknown_next = load volatile i32, i32* %unknown_mem
+ br i1 %be_taken, label %loop, label %leave
+
+leave:
+; We can fold %unknown_phi even though the backedge value for it is completely
+; unknown, since we can prove that the loop's backedge taken count is 0.
+
+; CHECK: leave:
+; CHECK: ret i32 %unknown_init
+ %exit_val = phi i32 [ %unknown_phi, %loop ]
+ ret i32 %exit_val
+}