[PATCH] D145395: [SCEV] Also strengthen flags for post-increment.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 08:52:18 PST 2023
fhahn created this revision.
fhahn added reviewers: reames, nikic, mkazantsev.
Herald added subscribers: StephenFan, javed.absar, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.
Also strengthen the flags for the post-increment SCEV, as suggested by
@mkazantsev.
Depends on D144050 <https://reviews.llvm.org/D144050>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145395
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/solve-quadratic-i1.ll
Index: llvm/test/Analysis/ScalarEvolution/solve-quadratic-i1.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/solve-quadratic-i1.ll
+++ llvm/test/Analysis/ScalarEvolution/solve-quadratic-i1.ll
@@ -9,7 +9,7 @@
; CHECK-NEXT: %v0 = phi i16 [ 2, %b0 ], [ %v2, %b1 ]
; CHECK-NEXT: --> {2,+,1}<nuw><nsw><%b1> U: [2,4) S: [2,4) Exits: 3 LoopDispositions: { %b1: Computable }
; CHECK-NEXT: %v1 = phi i16 [ 1, %b0 ], [ %v3, %b1 ]
-; CHECK-NEXT: --> {1,+,2,+,1}<%b1> U: full-set S: full-set Exits: 3 LoopDispositions: { %b1: Computable }
+; CHECK-NEXT: --> {1,+,2,+,1}<nsw><%b1> U: [1,-32768) S: [1,-32768) Exits: 3 LoopDispositions: { %b1: Computable }
; CHECK-NEXT: %v2 = add nsw i16 %v0, 1
; CHECK-NEXT: --> {3,+,1}<nuw><nsw><%b1> U: [3,5) S: [3,5) Exits: 4 LoopDispositions: { %b1: Computable }
; CHECK-NEXT: %v3 = add nsw i16 %v1, %v0
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -5670,9 +5670,8 @@
insertValueToMap(PN, PHISCEV);
if (auto *AR = dyn_cast<SCEVAddRecExpr>(PHISCEV)) {
- setNoWrapFlags(const_cast<SCEVAddRecExpr *>(AR),
- (SCEV::NoWrapFlags)(AR->getNoWrapFlags() |
- proveNoWrapViaConstantRanges(AR)));
+ Flags = (SCEV::NoWrapFlags)(Flags | proveNoWrapViaConstantRanges(AR));
+ setNoWrapFlags(const_cast<SCEVAddRecExpr *>(AR), Flags);
}
// We can add Flags to the post-inc expression only if we
@@ -5801,9 +5800,9 @@
insertValueToMap(PN, PHISCEV);
if (auto *AR = dyn_cast<SCEVAddRecExpr>(PHISCEV)) {
- setNoWrapFlags(const_cast<SCEVAddRecExpr *>(AR),
- (SCEV::NoWrapFlags)(AR->getNoWrapFlags() |
- proveNoWrapViaConstantRanges(AR)));
+
+ Flags = (SCEV::NoWrapFlags)(Flags | proveNoWrapViaConstantRanges(AR));
+ setNoWrapFlags(const_cast<SCEVAddRecExpr *>(AR), Flags);
}
// We can add Flags to the post-inc expression only if we
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145395.502675.patch
Type: text/x-patch
Size: 2198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230306/39a43282/attachment.bin>
More information about the llvm-commits
mailing list