[PATCH] D105941: [ScalarEvolution] Make isKnownNonZero handle more cases.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 13 14:51:50 PDT 2021
efriedma created this revision.
efriedma added reviewers: reames, mkazantsev, nikic.
Herald added a subscriber: hiraditya.
efriedma requested review of this revision.
Herald added a project: LLVM.
Using an unsigned range instead of signed ranges is a bit more precise.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105941
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/trip-count9.ll
Index: llvm/test/Analysis/ScalarEvolution/trip-count9.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/trip-count9.ll
+++ llvm/test/Analysis/ScalarEvolution/trip-count9.ll
@@ -311,9 +311,9 @@
define void @even_start1(i4 %n) {
; CHECK-LABEL: 'even_start1'
; CHECK-NEXT: Determining loop execution counts for: @even_start1
-; CHECK-NEXT: Loop %loop: backedge-taken count is (-2 + (2 smax (2 * %n)))<nsw>
+; CHECK-NEXT: Loop %loop: backedge-taken count is (-2 + (2 * %n))
; CHECK-NEXT: Loop %loop: max backedge-taken count is 4
-; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-2 + (2 smax (2 * %n)))<nsw>
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-2 + (2 * %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
@@ -333,9 +333,9 @@
define void @even_start1_step2(i4 %n) {
; CHECK-LABEL: 'even_start1_step2'
; CHECK-NEXT: Determining loop execution counts for: @even_start1_step2
-; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + (3 smax (2 * %n)))<nsw> /u 2)
+; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + (2 * %n)) /u 2)
; CHECK-NEXT: Loop %loop: max backedge-taken count is 2
-; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-2 + (3 smax (2 * %n)))<nsw> /u 2)
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-2 + (2 * %n)) /u 2)
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
@@ -443,9 +443,9 @@
define void @even_nsw_start1(i4 %n) {
; CHECK-LABEL: 'even_nsw_start1'
; CHECK-NEXT: Determining loop execution counts for: @even_nsw_start1
-; CHECK-NEXT: Loop %loop: backedge-taken count is (-2 + (2 smax (2 * %n)))<nsw>
+; CHECK-NEXT: Loop %loop: backedge-taken count is (-2 + (2 * %n))
; CHECK-NEXT: Loop %loop: max backedge-taken count is 4
-; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-2 + (2 smax (2 * %n)))<nsw>
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-2 + (2 * %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
@@ -465,9 +465,9 @@
define void @even_nsw_start1_step2(i4 %n) {
; CHECK-LABEL: 'even_nsw_start1_step2'
; CHECK-NEXT: Determining loop execution counts for: @even_nsw_start1_step2
-; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + (3 smax (2 * %n)))<nsw> /u 2)
+; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + (2 * %n)) /u 2)
; CHECK-NEXT: Loop %loop: max backedge-taken count is 2
-; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-2 + (3 smax (2 * %n)))<nsw> /u 2)
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-2 + (2 * %n)) /u 2)
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9822,7 +9822,7 @@
}
bool ScalarEvolution::isKnownNonZero(const SCEV *S) {
- return isKnownNegative(S) || isKnownPositive(S);
+ return getUnsignedRangeMin(S) != 0;
}
std::pair<const SCEV *, const SCEV *>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105941.358434.patch
Type: text/x-patch
Size: 3211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210713/d7f1443d/attachment.bin>
More information about the llvm-commits
mailing list