[llvm-branch-commits] [llvm] [DA] Fix overflow of calculation in weakCrossingSIVtest (PR #188450)
Ryotaro Kasuga via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Mar 25 06:06:52 PDT 2026
================
@@ -1454,17 +1454,23 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff,
if (const SCEV *UpperBound =
collectUpperBound(CurSrcLoop, Delta->getType())) {
LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n");
- const SCEV *ConstantTwo = SE->getConstant(UpperBound->getType(), 2);
- const SCEV *ML =
- SE->getMulExpr(SE->getMulExpr(ConstCoeff, UpperBound), ConstantTwo);
- LLVM_DEBUG(dbgs() << "\t ML = " << *ML << "\n");
- if (SE->isKnownPredicate(CmpInst::ICMP_SGT, Delta, ML)) {
+ ConstantRange UBRange = SE->getSignedRange(UpperBound);
+ ConstantRange MLRange =
+ UBRange.smul_fast(ConstCoeff->getAPInt())
+ .smul_fast(APInt(Distance.getBitWidth(), 2, true));
+ ConstantRange DeltaRange(ConstDelta->getAPInt());
+ LLVM_DEBUG(dbgs() << "\t UBRange = " << UBRange << "\n");
+ LLVM_DEBUG(dbgs() << "\t MLRange = " << MLRange << "\n");
+ LLVM_DEBUG(dbgs() << "\t DeltaRange = " << DeltaRange << "\n");
+
+ if (DeltaRange.intersectWith(MLRange).isEmptySet() &&
+ DeltaRange.getSignedMin().sgt(MLRange.getSignedMax())) {
----------------
kasuga-fj wrote:
```suggestion
if (APDelta.sgt(MLRange.getSignedMax())) {
```
https://github.com/llvm/llvm-project/pull/188450
More information about the llvm-branch-commits
mailing list