[llvm] [DA] Consolidate the logic for checking overlap at the boundary (NFCI) (PR #189341)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 02:21:20 PDT 2026
https://github.com/kasuga-fj created https://github.com/llvm/llvm-project/pull/189341
In the Weak Crossing SIV test, there were two places where we checked the dependency at the boundary, one is at the first iteration, and the other is at the last iteration. Now the former can be merged into the latter. There used to be an edge case when the coefficient is zero, and we had an explicit check for that. This patch removes that check as well, by moving the boundary check after the assertion that ensures the (maybe negated) coefficient is positive.
>From e25f213d25a6e0362a9e5dc775e354db0f4c0266 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Mon, 30 Mar 2026 09:04:41 +0000
Subject: [PATCH] [DA] Consolidate the logic that checks overlap at the
boundary (NFCI)
---
llvm/lib/Analysis/DependenceAnalysis.cpp | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index de08de7da5f06..ab112c2fa4a85 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -1386,17 +1386,6 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEVAddRecExpr *Src,
Level--;
const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n");
- if (Delta->isZero() && SE->isKnownNonZero(Coeff)) {
- Result.DV[Level].Direction &= ~Dependence::DVEntry::LT;
- Result.DV[Level].Direction &= ~Dependence::DVEntry::GT;
- ++WeakCrossingSIVsuccesses;
- if (!Result.DV[Level].Direction) {
- ++WeakCrossingSIVindependence;
- return true;
- }
- Result.DV[Level].Distance = Delta; // = 0
- return false;
- }
const SCEVConstant *ConstCoeff = dyn_cast<SCEVConstant>(Coeff);
if (!ConstCoeff)
return false;
@@ -1429,7 +1418,7 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEVAddRecExpr *Src,
LLVM_DEBUG(dbgs() << "\t SrcRange = " << SrcRange << "\n");
LLVM_DEBUG(dbgs() << "\t DstRange = " << DstRange << "\n");
if (SrcRange.intersectWith(DstRange).isSingleElement()) {
- // The ranges touch at exactly one value (i = i' = BTC).
+ // The ranges touch at exactly one value (i = i' = 0 or i = i' = BTC).
Result.DV[Level].Direction &= ~Dependence::DVEntry::LT;
Result.DV[Level].Direction &= ~Dependence::DVEntry::GT;
++WeakCrossingSIVsuccesses;
More information about the llvm-commits
mailing list