[llvm] [DA] Fix zero coeff bug in Strong SIV test with runtime assumptions (#149991) (PR #155037)
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 28 05:28:20 PST 2025
================
@@ -1368,7 +1369,35 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
Result.DV[Level].Direction &= Dependence::DVEntry::EQ;
++StrongSIVsuccesses;
} else if (Delta->isZero()) {
- // since 0/X == 0
+ // Check if coefficient could be zero. If so, 0/0 is undefined and we
+ // cannot conclude that only same-iteration dependencies exist.
+ // When coeff=0, all iterations access the same location.
+ if (isa<SCEVUnknown>(Coeff)) {
----------------
sebpop wrote:
I rewrote this code like this to avoid enumerating all possible expressions that Coeff can take at this location:
```
if (isa<SCEVConstant>(Coeff) || SE->isKnownNonZero(Coeff)) {
LLVM_DEBUG(
dbgs() << "\t Coefficient proven non-zero by SCEV analysis\n");
} else {
// Cannot prove at compile time, would need runtime assumption.
[...]
}
```
https://github.com/llvm/llvm-project/pull/155037
More information about the llvm-commits
mailing list