[llvm] 24a46f2 - [Test] Add two more tests for symtolic count with arith and logical AND
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 22:06:24 PST 2022
Author: Max Kazantsev
Date: 2022-12-08T13:05:44+07:00
New Revision: 24a46f2117c2a6d7bfcfaec6817cde63f8555940
URL: https://github.com/llvm/llvm-project/commit/24a46f2117c2a6d7bfcfaec6817cde63f8555940
DIFF: https://github.com/llvm/llvm-project/commit/24a46f2117c2a6d7bfcfaec6817cde63f8555940.diff
LOG: [Test] Add two more tests for symtolic count with arith and logical AND
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/symbolic_max_exit_count.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/symbolic_max_exit_count.ll b/llvm/test/Analysis/ScalarEvolution/symbolic_max_exit_count.ll
index e63f7e45e8fc4..be31a2f484e0e 100644
--- a/llvm/test/Analysis/ScalarEvolution/symbolic_max_exit_count.ll
+++ b/llvm/test/Analysis/ScalarEvolution/symbolic_max_exit_count.ll
@@ -437,3 +437,151 @@ backedge:
exit:
ret i32 0
}
+
+; TODO: Symbolic max can be start1 umin start2
+define i32 @test_two_phis_arithmetic_and(i32 %start_1, i32 %start_2, i32 %len) {
+; CHECK-LABEL: 'test_two_phis_arithmetic_and'
+; CHECK-NEXT: Classifying expressions for: @test_two_phis_arithmetic_and
+; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
+; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
+; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %scam_1 = call i1 @cond()
+; CHECK-NEXT: --> %scam_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %c1 = and i1 %zero_check_1, %scam_1
+; CHECK-NEXT: --> (%zero_check_1 umin %scam_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %scam_2 = call i1 @cond()
+; CHECK-NEXT: --> %scam_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %c2 = and i1 %zero_check_2, %scam_2
+; CHECK-NEXT: --> (%zero_check_2 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %merged_cond = and i1 %c1, %c2
+; CHECK-NEXT: --> (%zero_check_1 umin %zero_check_2 umin %scam_1 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %iv.minus.1 = add i32 %iv_1, -1
+; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
+; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
+; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %loop_cond = call i1 @cond()
+; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: Determining loop execution counts for: @test_two_phis_arithmetic_and
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
+; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is -1
+; CHECK-NEXT: symbolic max exit count for loop: -1
+; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
+;
+entry:
+ br label %loop
+
+loop:
+ %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
+ %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
+ %scam_1 = call i1 @cond()
+ %zero_check_1 = icmp ne i32 %iv_1, 0
+ %c1 = and i1 %zero_check_1, %scam_1
+ %scam_2 = call i1 @cond()
+ %zero_check_2 = icmp ne i32 %iv_2, 0
+ %c2 = and i1 %zero_check_2, %scam_2
+ %merged_cond = and i1 %c1, %c2
+ br i1 %merged_cond, label %range_check_block, label %failed_1
+
+range_check_block:
+ %iv.minus.1 = add i32 %iv_1, -1
+ %range_check = icmp ult i32 %iv.minus.1, %len
+ br i1 %range_check, label %backedge, label %failed_2
+
+backedge:
+ %iv_1.next = add i32 %iv_1, -1
+ %iv_2.next = add i32 %iv_2, -1
+ %loop_cond = call i1 @cond()
+ br i1 %loop_cond, label %done, label %loop
+
+done:
+ ret i32 %iv_2
+
+failed_1:
+ ret i32 -1
+
+failed_2:
+ ret i32 -2
+}
+
+; TODO: Symbolic max can be start1 umin_seq start2
+define i32 @test_two_phis_logical_and(i32 %start_1, i32 %start_2, i32 %len) {
+; CHECK-LABEL: 'test_two_phis_logical_and'
+; CHECK-NEXT: Classifying expressions for: @test_two_phis_logical_and
+; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
+; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
+; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %scam_1 = call i1 @cond()
+; CHECK-NEXT: --> %scam_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %c1 = and i1 %zero_check_1, %scam_1
+; CHECK-NEXT: --> (%zero_check_1 umin %scam_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %scam_2 = call i1 @cond()
+; CHECK-NEXT: --> %scam_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %c2 = and i1 %zero_check_2, %scam_2
+; CHECK-NEXT: --> (%zero_check_2 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %merged_cond = select i1 %c1, i1 true, i1 %c2
+; CHECK-NEXT: --> (true + ((true + (%zero_check_1 umin %scam_1)) umin_seq (true + (%zero_check_2 umin %scam_2)))) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %iv.minus.1 = add i32 %iv_1, -1
+; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
+; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
+; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %loop_cond = call i1 @cond()
+; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: Determining loop execution counts for: @test_two_phis_logical_and
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
+; 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 range_check_block: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
+;
+entry:
+ br label %loop
+
+loop:
+ %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
+ %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
+ %scam_1 = call i1 @cond()
+ %zero_check_1 = icmp ne i32 %iv_1, 0
+ %c1 = and i1 %zero_check_1, %scam_1
+ %scam_2 = call i1 @cond()
+ %zero_check_2 = icmp ne i32 %iv_2, 0
+ %c2 = and i1 %zero_check_2, %scam_2
+ %merged_cond = select i1 %c1, i1 true, i1 %c2
+ br i1 %merged_cond, label %range_check_block, label %failed_1
+
+range_check_block:
+ %iv.minus.1 = add i32 %iv_1, -1
+ %range_check = icmp ult i32 %iv.minus.1, %len
+ br i1 %range_check, label %backedge, label %failed_2
+
+backedge:
+ %iv_1.next = add i32 %iv_1, -1
+ %iv_2.next = add i32 %iv_2, -1
+ %loop_cond = call i1 @cond()
+ br i1 %loop_cond, label %done, label %loop
+
+done:
+ ret i32 %iv_2
+
+failed_1:
+ ret i32 -1
+
+failed_2:
+ ret i32 -2
+}
More information about the llvm-commits
mailing list