[llvm-branch-commits] [llvm] [DA] Hoist division check for early exit in weakCrossingSIVtest (NFC) (PR #188442)
Ryotaro Kasuga via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Mar 25 03:50:30 PDT 2026
================
@@ -1428,6 +1428,27 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff,
return true;
}
+ // check that Coeff divides Delta
+ APInt APDelta = ConstDelta->getAPInt();
+ APInt APCoeff = ConstCoeff->getAPInt();
+ APInt Distance = APDelta; // these need to be initialzed
+ APInt Remainder = APDelta;
+ APInt::sdivrem(APDelta, APCoeff, Distance, Remainder);
+ LLVM_DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n");
+ if (Remainder != 0) {
+ // Coeff doesn't divide Delta, no dependence
+ ++WeakCrossingSIVindependence;
+ ++WeakCrossingSIVsuccesses;
+ return true;
+ }
+ LLVM_DEBUG(dbgs() << "\t Distance = " << Distance << "\n");
+ // if 2*Coeff doesn't divide Delta, then the equal direction isn't possible
+ if (Distance[0]) {
+ // Equal direction isn't possible
+ Result.DV[Level].Direction &= ~Dependence::DVEntry::EQ;
+ ++WeakCrossingSIVsuccesses;
----------------
kasuga-fj wrote:
I don't know how useful this metrics is, but with this change, the value could be incremented twice within a single invocation (when `Delta % (2*Coeff) != 0` and `Delta >s ML`).
https://github.com/llvm/llvm-project/pull/188442
More information about the llvm-branch-commits
mailing list