================
@@ -1293,9 +1316,40 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff,
const SCEV *SrcConst,
Result.DV[Level].Distance = Delta; // since X/1 == X
NewConstraint.setDistance(Delta, CurLoop);
} else {
- Result.Consistent = false;
- NewConstraint.setLine(Coeff, SE->getNegativeSCEV(Coeff),
- SE->getNegativeSCEV(Delta), CurLoop);
+ // Try symbolic division: Distance = Delta / Coeff.
+ if (const SCEV *Distance = SE->getUDivExactExpr(Delta, Coeff)) {
+ LLVM_DEBUG(dbgs() << "\t Symbolic distance = " << *Distance <<
"\n");
+ Result.DV[Level].Distance = Distance;
+ NewConstraint.setDistance(Distance, CurLoop);
+ } else {
+ // Cannot compute exact division - check if we can add runtime
+ // assumptions.
+ if (isa<SCEVUnknown>(Coeff) && !SE->isKnownNonZero(Coeff)) {
+ // Add runtime assumption that coefficient is non-zero for division.
+ const SCEV *Zero = SE->getZero(Coeff->getType());
+ const SCEVPredicate *NonZeroPred =
+ SE->getComparePredicate(ICmpInst::ICMP_NE, Coeff, Zero);
+ if (UnderRuntimeAssumptions) {
+ SmallVector<const SCEVPredicate *, 4> NewPreds(
+ Assumptions.getPredicates());
+ NewPreds.push_back(NonZeroPred);
+ const_cast<DependenceInfo *>(this)->Assumptions =
+ SCEVUnionPredicate(NewPreds, *SE);
----------------
sushgokh wrote:
why are we adding constraint once again when we have already added below
constraint?
```
const SCEVPredicate *BoundPred =
SE->getComparePredicate(ICmpInst::ICMP_SLE, AbsDelta, Product);
```
https://github.com/llvm/llvm-project/pull/157738
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits