[llvm] 383a670 - [SCEV] Add early exit tests with alignment assumptions.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 02:30:27 PDT 2024
Author: Florian Hahn
Date: 2024-10-02T10:30:04+01:00
New Revision: 383a67042a30c12ca492d306f2f6a2459764022f
URL: https://github.com/llvm/llvm-project/commit/383a67042a30c12ca492d306f2f6a2459764022f
DIFF: https://github.com/llvm/llvm-project/commit/383a67042a30c12ca492d306f2f6a2459764022f.diff
LOG: [SCEV] Add early exit tests with alignment assumptions.
Precommit tests from https://github.com/llvm/llvm-project/pull/108632.
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll b/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
index 124d895e5aef50..42706df82f37cd 100644
--- a/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
+++ b/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
@@ -1625,6 +1625,204 @@ exit:
ret void
}
+define void @ptr_induction_early_exit_eq_1_with_align_on_load(ptr %a, ptr %b, ptr %c) {
+; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_with_align_on_load'
+; CHECK-NEXT: Classifying expressions for: @ptr_induction_early_exit_eq_1_with_align_on_load
+; CHECK-NEXT: %a_ = load ptr, ptr %a, align 8, !align !0
+; CHECK-NEXT: --> %a_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)
+; CHECK-NEXT: %b_ = load ptr, ptr %b, align 8, !align !0
+; CHECK-NEXT: --> %b_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)
+; CHECK-NEXT: %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]
+; CHECK-NEXT: --> {%a_,+,8}<nuw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %ld1 = load ptr, ptr %ptr.iv, align 8
+; CHECK-NEXT: --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+; CHECK-NEXT: --> {(8 + %a_),+,8}<nw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: Determining loop execution counts for: @ptr_induction_early_exit_eq_1_with_align_on_load
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 2305843009213693951
+; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+;
+entry:
+ %a_ = load ptr, ptr %a, !align !{i64 8}
+ %b_ = load ptr, ptr %b, !align !{i64 8}
+ %cmp = icmp eq ptr %a_, %b_
+ br i1 %cmp, label %exit, label %loop
+
+loop:
+ %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]
+ %ld1 = load ptr, ptr %ptr.iv, align 8
+ %earlyexitcond = icmp eq ptr %ld1, %c
+ br i1 %earlyexitcond, label %exit, label %loop.inc
+
+loop.inc:
+ %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+ %exitcond = icmp eq ptr %ptr.iv.next, %b_
+ br i1 %exitcond, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @ptr_induction_early_exit_eq_1_with_align_on_arguments(ptr align 8 %a, ptr align 8 %b, ptr %c) {
+; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_with_align_on_arguments'
+; CHECK-NEXT: Classifying expressions for: @ptr_induction_early_exit_eq_1_with_align_on_arguments
+; CHECK-NEXT: %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a, %entry ]
+; CHECK-NEXT: --> {%a,+,8}<nuw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %ld1 = load ptr, ptr %ptr.iv, align 8
+; CHECK-NEXT: --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+; CHECK-NEXT: --> {(8 + %a),+,8}<nw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: Determining loop execution counts for: @ptr_induction_early_exit_eq_1_with_align_on_arguments
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)
+; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 2305843009213693951
+; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)
+; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)
+;
+entry:
+ %cmp = icmp eq ptr %a, %b
+ br i1 %cmp, label %exit, label %loop
+
+loop:
+ %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a, %entry ]
+ %ld1 = load ptr, ptr %ptr.iv, align 8
+ %earlyexitcond = icmp eq ptr %ld1, %c
+ br i1 %earlyexitcond, label %exit, label %loop.inc
+
+loop.inc:
+ %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+ %exitcond = icmp eq ptr %ptr.iv.next, %b
+ br i1 %exitcond, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @ptr_induction_early_exit_eq_1_align_assumption_1(ptr %a, ptr %b, ptr %c) {
+; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_align_assumption_1'
+; CHECK-NEXT: Classifying expressions for: @ptr_induction_early_exit_eq_1_align_assumption_1
+; CHECK-NEXT: %a_ = load ptr, ptr %a, align 8
+; CHECK-NEXT: --> %a_ U: full-set S: full-set
+; CHECK-NEXT: %b_ = load ptr, ptr %b, align 8
+; CHECK-NEXT: --> %b_ U: full-set S: full-set
+; CHECK-NEXT: %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]
+; CHECK-NEXT: --> {%a_,+,8}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %ld1 = load ptr, ptr %ptr.iv, align 8
+; CHECK-NEXT: --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+; CHECK-NEXT: --> {(8 + %a_),+,8}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: Determining loop execution counts for: @ptr_induction_early_exit_eq_1_align_assumption_1
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for loop.inc: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: predicated exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+; CHECK-EMPTY:
+; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
+; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for loop.inc: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: predicated symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+; CHECK-EMPTY:
+; CHECK-NEXT: Loop %loop: Predicated constant max backedge-taken count is i64 2305843009213693951
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+; CHECK-NEXT: Loop %loop: Predicated symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+;
+entry:
+ %a_ = load ptr, ptr %a
+ call void @llvm.assume(i1 true) [ "align"(ptr %a_, i64 8) ]
+ %b_ = load ptr, ptr %b
+ call void @llvm.assume(i1 true) [ "align"(ptr %b_, i64 8) ]
+ %cmp = icmp eq ptr %a_, %b_
+ br i1 %cmp, label %exit, label %loop
+
+loop:
+ %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]
+ %ld1 = load ptr, ptr %ptr.iv, align 8
+ %earlyexitcond = icmp eq ptr %ld1, %c
+ br i1 %earlyexitcond, label %exit, label %loop.inc
+
+loop.inc:
+ %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+ %exitcond = icmp eq ptr %ptr.iv.next, %b_
+ br i1 %exitcond, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @ptr_induction_early_exit_eq_1_align_assumption_2(ptr %a, ptr %b, ptr %c) {
+; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_align_assumption_2'
+; CHECK-NEXT: Classifying expressions for: @ptr_induction_early_exit_eq_1_align_assumption_2
+; CHECK-NEXT: %a_ = load ptr, ptr %a, align 8
+; CHECK-NEXT: --> %a_ U: full-set S: full-set
+; CHECK-NEXT: %b_ = load ptr, ptr %b, align 8
+; CHECK-NEXT: --> %b_ U: full-set S: full-set
+; CHECK-NEXT: %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]
+; CHECK-NEXT: --> {%a_,+,8}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %ld1 = load ptr, ptr %ptr.iv, align 8
+; CHECK-NEXT: --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+; CHECK-NEXT: --> {(8 + %a_),+,8}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: Determining loop execution counts for: @ptr_induction_early_exit_eq_1_align_assumption_2
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for loop.inc: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: predicated exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+; CHECK-EMPTY:
+; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
+; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for loop.inc: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: predicated symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+; CHECK-EMPTY:
+; CHECK-NEXT: Loop %loop: Predicated constant max backedge-taken count is i64 2305843009213693951
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+; CHECK-NEXT: Loop %loop: Predicated symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)
+; CHECK-NEXT: Predicates:
+; CHECK-NEXT: Equal predicate: (zext i3 ((trunc i64 (ptrtoint ptr %b_ to i64) to i3) + (-1 * (trunc i64 (ptrtoint ptr %a_ to i64) to i3))) to i64) == 0
+;
+entry:
+ %a_ = load ptr, ptr %a
+ %b_ = load ptr, ptr %b
+ call void @llvm.assume(i1 true) [ "align"(ptr %a_, i64 8) ]
+ call void @llvm.assume(i1 true) [ "align"(ptr %b_, i64 8) ]
+ %cmp = icmp eq ptr %a_, %b_
+ br i1 %cmp, label %exit, label %loop
+
+loop:
+ %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]
+ %ld1 = load ptr, ptr %ptr.iv, align 8
+ %earlyexitcond = icmp eq ptr %ld1, %c
+ br i1 %earlyexitcond, label %exit, label %loop.inc
+
+loop.inc:
+ %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 8
+ %exitcond = icmp eq ptr %ptr.iv.next, %b_
+ br i1 %exitcond, label %exit, label %loop
+
+exit:
+ ret void
+}
+
define void @ptr_induction_early_exit_eq_2(ptr %a, i64 %n, ptr %c) {
; CHECK-LABEL: 'ptr_induction_early_exit_eq_2'
; CHECK-NEXT: Classifying expressions for: @ptr_induction_early_exit_eq_2
More information about the llvm-commits
mailing list