[llvm] 72f3f67 - [test] Add a couple extra tests for recurrence matching in unreachable code
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 20 10:08:59 PDT 2021
Author: Philip Reames
Date: 2021-04-20T10:08:50-07:00
New Revision: 72f3f6713710c6d4cf7b1977cae94cefe9fe4a99
URL: https://github.com/llvm/llvm-project/commit/72f3f6713710c6d4cf7b1977cae94cefe9fe4a99
DIFF: https://github.com/llvm/llvm-project/commit/72f3f6713710c6d4cf7b1977cae94cefe9fe4a99.diff
LOG: [test] Add a couple extra tests for recurrence matching in unreachable code
These are salvaged from D100004 as we took a different approach to the fix.
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 0b9525ddf4edf..962252559af1d 100644
--- a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
+++ b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
@@ -440,6 +440,60 @@ unreachable:
br label %for.cond2295
}
+; Was pr49856. We can match the recurrence without a loop
+; since dominance collapses in unreachable code. Conceptually,
+; this is a recurrence which only executes one iteration.
+define void @nonloop_recurrence() {
+; CHECK-LABEL: 'nonloop_recurrence'
+; CHECK-NEXT: Classifying expressions for: @nonloop_recurrence
+; CHECK-NEXT: %tmp = phi i32 [ 2, %bb ], [ %tmp2, %bb3 ]
+; CHECK-NEXT: --> %tmp U: [1,-2147483648) S: [0,-2147483648)
+; CHECK-NEXT: %tmp2 = add nuw nsw i32 %tmp, 1
+; CHECK-NEXT: --> (1 + %tmp)<nuw> U: [1,-2147483647) S: [1,-2147483647)
+; CHECK-NEXT: Determining loop execution counts for: @nonloop_recurrence
+;
+bb:
+ br label %bb1
+
+bb1: ; preds = %bb3, %bb
+ %tmp = phi i32 [ 2, %bb ], [ %tmp2, %bb3 ]
+ %tmp2 = add nuw nsw i32 %tmp, 1
+ ret void
+
+bb3: ; No predecessors!
+ br label %bb1
+}
+
+; Tweak of pr49856 test case - analogous, but there is a loop
+; it's trip count simply doesn't relate to the single iteration
+; "recurrence" we found.
+define void @nonloop_recurrence_2() {
+; CHECK-LABEL: 'nonloop_recurrence_2'
+; CHECK-NEXT: Classifying expressions for: @nonloop_recurrence_2
+; CHECK-NEXT: %tmp = phi i32 [ 2, %loop ], [ %tmp2, %bb3 ]
+; CHECK-NEXT: --> %tmp U: [1,-2147483648) S: [0,-2147483648) Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %tmp2 = add nuw nsw i32 %tmp, 1
+; CHECK-NEXT: --> (1 + %tmp)<nuw> U: [1,-2147483647) S: [1,-2147483647) Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: Determining loop execution counts for: @nonloop_recurrence_2
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
+; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
+;
+bb:
+ br label %loop
+
+loop:
+ br label %bb1
+bb1: ; preds = %bb3, %loop
+ %tmp = phi i32 [ 2, %loop ], [ %tmp2, %bb3 ]
+ %tmp2 = add nuw nsw i32 %tmp, 1
+ br label %loop
+
+bb3: ; No predecessors!
+ br label %bb1
+}
+
+
; Next batch of tests show where we can get tighter ranges on ashr/lshr
; by using the trip count information on the loop.
More information about the llvm-commits
mailing list