[PATCH] D130694: [SCEV] Avoid repeated proveNoSignedWrapViaInduction calls.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 01:15:21 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG214e2d8fe572: [SCEV] Avoid repeated proveNoSignedWrapViaInduction calls. (authored by fhahn).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130694/new/
https://reviews.llvm.org/D130694
Files:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -4958,6 +4958,10 @@
if (!AR->isAffine())
return Result;
+ // This function can be expensive, only try to prove NSW once per AddRec.
+ if (!SignedWrapViaInductionTried.insert(AR).second)
+ return Result;
+
const SCEV *Step = AR->getStepRecurrence(*this);
const Loop *L = AR->getLoop();
@@ -13584,8 +13588,10 @@
HasRecMap.erase(S);
MinTrailingZerosCache.erase(S);
- if (auto *AR = dyn_cast<SCEVAddRecExpr>(S))
+ if (auto *AR = dyn_cast<SCEVAddRecExpr>(S)) {
UnsignedWrapViaInductionTried.erase(AR);
+ SignedWrapViaInductionTried.erase(AR);
+ }
auto ExprIt = ExprValueMap.find(S);
if (ExprIt != ExprValueMap.end()) {
Index: llvm/include/llvm/Analysis/ScalarEvolution.h
===================================================================
--- llvm/include/llvm/Analysis/ScalarEvolution.h
+++ llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -2119,6 +2119,10 @@
/// tried.
SmallPtrSet<const SCEVAddRecExpr *, 16> UnsignedWrapViaInductionTried;
+ /// Set of AddRecs for which proving NSW via an induction has already been
+ /// tried.
+ SmallPtrSet<const SCEVAddRecExpr *, 16> SignedWrapViaInductionTried;
+
/// The head of a linked list of all SCEVUnknown values that have been
/// allocated. This is used by releaseMemory to locate them all and call
/// their destructors.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130694.448541.patch
Type: text/x-patch
Size: 1537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220729/3bf9f8f6/attachment.bin>
More information about the llvm-commits
mailing list