[llvm] [DA] use NSW arithmetic (PR #116632)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 01:27:59 PST 2025
================
@@ -3116,11 +3116,9 @@ const SCEV *DependenceInfo::addToCoefficient(const SCEV *Expr,
const Loop *TargetLoop,
const SCEV *Value) const {
const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Expr);
- if (!AddRec) // create a new addRec
- return SE->getAddRecExpr(Expr,
- Value,
- TargetLoop,
- SCEV::FlagAnyWrap); // Worst case, with no info.
+ if (!AddRec)
+ return SE->getAddRecExpr(Expr, Value, TargetLoop, SCEV::FlagNSW);
----------------
Meinersbur wrote:
> all non-linear memory access functions have been filtered out by this time.
Where does this happen? If it already ensured that no wrap happens it should be safe.
If I am nitpicky, if the original offset expression is NSW, it would be still possible that intermediate represetions use for dependencies could wrap. E.g. two loops, one with large prime stride p, the other with large prime stride q. They have a theoretical dependence at p*q which might be outside integer precision.
Consider adding a comment into the code why NSW is OK.
https://github.com/llvm/llvm-project/pull/116632
More information about the llvm-commits
mailing list