[PATCH] D109782: [SCEV] Stop applying contextual flags in applyLoopGuards
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 14 14:15:12 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0dd755f02742: [SCEV] Stop applying contextual flags in applyLoopGuards (authored by reames).
Changed prior to commit:
https://reviews.llvm.org/D109782?vs=372550&id=372564#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109782/new/
https://reviews.llvm.org/D109782
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -13495,6 +13495,11 @@
const SCEV *ScalarEvolution::applyLoopGuards(const SCEV *Expr, const Loop *L) {
auto CollectCondition = [&](ICmpInst::Predicate Predicate, const SCEV *LHS,
const SCEV *RHS, ValueToSCEVMapTy &RewriteMap) {
+ // WARNING: It is generally unsound to apply any wrap flags to the proposed
+ // replacement SCEV which isn't directly implied by the structure of that
+ // SCEV. In particular, using contextual facts to imply flags is *NOT*
+ // legal. See the scoping rules for flags in the header to understand why.
+
// If we have LHS == 0, check if LHS is computing a property of some unknown
// SCEV %v which we can rewrite %v to express explicitly.
const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS);
@@ -13507,10 +13512,7 @@
if (matchURem(LHS, URemLHS, URemRHS)) {
if (const SCEVUnknown *LHSUnknown = dyn_cast<SCEVUnknown>(URemLHS)) {
Value *V = LHSUnknown->getValue();
- auto Multiple =
- getMulExpr(getUDivExpr(URemLHS, URemRHS), URemRHS,
- (SCEV::NoWrapFlags)(SCEV::FlagNUW | SCEV::FlagNSW));
- RewriteMap[V] = Multiple;
+ RewriteMap[V] = getMulExpr(getUDivExpr(URemLHS, URemRHS), URemRHS);
return;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109782.372564.patch
Type: text/x-patch
Size: 1512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210914/13ed9c8c/attachment.bin>
More information about the llvm-commits
mailing list