aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuoyu Qiu <cabbaken@outlook.com>2026-03-25 09:07:55 +0000
committerRuoyu Qiu <cabbaken@outlook.com>2026-03-26 07:00:38 +0000
commit92479504d789bb4adb9f28688c0138d0cf666c90 (patch)
tree5ec657e575ab37b0c743ba62e21def9cff09845d
parent8e2a5e37eaf638c536dd71cb685843e8cb2aed2c (diff)
downloadllvm-users/cabbaken/WeakCrossingSIVtest_refactor_1.tar.gz
llvm-users/cabbaken/WeakCrossingSIVtest_refactor_1.tar.bz2
llvm-users/cabbaken/WeakCrossingSIVtest_refactor_1.zip
[DA] Hoist division check for early exit in weakCrossingSIVtest (NFC)users/cabbaken/WeakCrossingSIVtest_refactor_1
This patch moves the check that `Coeff` divides `Delta` earlier in the function to enable an early exit. Potentially improve performance. Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
-rw-r--r--llvm/lib/Analysis/DependenceAnalysis.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 8d265e5a6b4e..6d449ae37440 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -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;
+ }
+
// We're certain that Delta > 0 and ConstCoeff > 0.
// Check Delta/(2*ConstCoeff) against upper loop bound
if (const SCEV *UpperBound =
@@ -1457,27 +1478,6 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff,
}
}
- // 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;
- }
return false;
}