[llvm] 4b8eb89 - [tests] Cover a case brought up in review of D98222
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 12 13:11:43 PST 2021
Author: Philip Reames
Date: 2021-03-12T13:11:25-08:00
New Revision: 4b8eb894bfc39b99072fa1d99a348a4022c0cbfc
URL: https://github.com/llvm/llvm-project/commit/4b8eb894bfc39b99072fa1d99a348a4022c0cbfc
DIFF: https://github.com/llvm/llvm-project/commit/4b8eb894bfc39b99072fa1d99a348a4022c0cbfc.diff
LOG: [tests] Cover a case brought up in review of D98222
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
index a81562f725ff..4eb9c9ea50a6 100644
--- a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
+++ b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
@@ -316,3 +316,70 @@ loop:
exit:
ret void
}
+
+; Loop varying (but tightly bounded) shift amount
+define void @test_shl6(i1 %c) {
+; CHECK-LABEL: 'test_shl6'
+; CHECK-NEXT: Classifying expressions for: @test_shl6
+; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,5) S: [0,5) Exits: 4 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv.shl = phi i64 [ 4, %entry ], [ %iv.shl.next, %loop ]
+; CHECK-NEXT: --> %iv.shl U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: 16 LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %iv.next = add i64 %iv, 1
+; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,6) S: [1,6) Exits: 5 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %shiftamt = and i64 %iv, 1
+; CHECK-NEXT: --> (zext i1 {false,+,true}<%loop> to i64) U: [0,2) S: [0,2) Exits: 0 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv.shl.next = shl i64 %iv.shl, %shiftamt
+; CHECK-NEXT: --> %iv.shl.next U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: 16 LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: Determining loop execution counts for: @test_shl6
+; CHECK-NEXT: Loop %loop: backedge-taken count is 4
+; CHECK-NEXT: Loop %loop: max backedge-taken count is 4
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 4
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %loop: Trip multiple is 5
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [0, %entry], [%iv.next, %loop]
+ %iv.shl = phi i64 [4, %entry], [%iv.shl.next, %loop]
+ %iv.next = add i64 %iv, 1
+ %shiftamt = and i64 %iv, 1
+ %iv.shl.next = shl i64 %iv.shl, %shiftamt
+ %cmp = icmp eq i64 %iv, 4
+ br i1 %cmp, label %exit, label %loop
+exit:
+ ret void
+}
+
+; Unanalyzeable shift amount
+define void @test_shl7(i1 %c, i64 %shiftamt) {
+; CHECK-LABEL: 'test_shl7'
+; CHECK-NEXT: Classifying expressions for: @test_shl7
+; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,5) S: [0,5) Exits: 4 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv.shl = phi i64 [ 4, %entry ], [ %iv.shl.next, %loop ]
+; CHECK-NEXT: --> %iv.shl U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %iv.next = add i64 %iv, 1
+; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,6) S: [1,6) Exits: 5 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv.shl.next = shl i64 %iv.shl, %shiftamt
+; CHECK-NEXT: --> %iv.shl.next U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: Determining loop execution counts for: @test_shl7
+; CHECK-NEXT: Loop %loop: backedge-taken count is 4
+; CHECK-NEXT: Loop %loop: max backedge-taken count is 4
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 4
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %loop: Trip multiple is 5
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [0, %entry], [%iv.next, %loop]
+ %iv.shl = phi i64 [4, %entry], [%iv.shl.next, %loop]
+ %iv.next = add i64 %iv, 1
+ %iv.shl.next = shl i64 %iv.shl, %shiftamt
+ %cmp = icmp eq i64 %iv, 4
+ br i1 %cmp, label %exit, label %loop
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list