[llvm] d74617b - [DA] Remove `DependenceInfo::removeMatchingExtensions` (#171809)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 09:12:56 PST 2026


Author: Ryotaro Kasuga
Date: 2026-02-16T17:12:48Z
New Revision: d74617b06f51605bf3c12753f5dc4d10381e2337

URL: https://github.com/llvm/llvm-project/commit/d74617b06f51605bf3c12753f5dc4d10381e2337
DIFF: https://github.com/llvm/llvm-project/commit/d74617b06f51605bf3c12753f5dc4d10381e2337.diff

LOG: [DA] Remove `DependenceInfo::removeMatchingExtensions` (#171809)

If two subscripts has same cast operation (`sext` or `zext`),
`removeMatchingExtensions` strips off them. Due to the following
reasons, remaining this function is not useful and risky:

- If the operand of the cast operation has proper nowrap properties,
SCEV usually strips off the cast operation automatically. It's not very
meaningful to do it on DA side.
- If the operand doesn't have nowrap properties, stripping off the cast
operation may lead to incorrect result. Especially, if it can be
negative, removing `zext` would change the interpretation of the value
in a signed sense.
- This function is part of the root cause of #148435.

Although I've not found any cases where incorrect results are produced
by this function, but I think it doesn't make sense to keep it. As far
as I have checked, there are no regressions after removing this
function.

Resolve #169809

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/DependenceAnalysis.h
    llvm/lib/Analysis/DependenceAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index 6963914d6a03d..528478ced1d9f 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -478,12 +478,6 @@ class DependenceInfo {
   /// array subscripts are signed.
   void unifySubscriptType(ArrayRef<Subscript *> Pairs);
 
-  /// removeMatchingExtensions - Examines a subscript pair.
-  /// If the source and destination are identically sign (or zero)
-  /// extended, it strips off the extension in an effort to
-  /// simplify the actual analysis.
-  void removeMatchingExtensions(Subscript *Pair);
-
   /// collectCommonLoops - Finds the set of loops from the LoopNest that
   /// have a level <= CommonLevels and are referred to by the SCEV Expression.
   void collectCommonLoops(const SCEV *Expression, const Loop *LoopNest,

diff  --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 51d0c32149330..f9eec7dfec169 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -1122,26 +1122,6 @@ void DependenceInfo::unifySubscriptType(ArrayRef<Subscript *> Pairs) {
   }
 }
 
-// removeMatchingExtensions - Examines a subscript pair.
-// If the source and destination are identically sign (or zero)
-// extended, it strips off the extension in an effect to simplify
-// the actual analysis.
-void DependenceInfo::removeMatchingExtensions(Subscript *Pair) {
-  const SCEV *Src = Pair->Src;
-  const SCEV *Dst = Pair->Dst;
-  if ((isa<SCEVZeroExtendExpr>(Src) && isa<SCEVZeroExtendExpr>(Dst)) ||
-      (isa<SCEVSignExtendExpr>(Src) && isa<SCEVSignExtendExpr>(Dst))) {
-    const SCEVIntegralCastExpr *SrcCast = cast<SCEVIntegralCastExpr>(Src);
-    const SCEVIntegralCastExpr *DstCast = cast<SCEVIntegralCastExpr>(Dst);
-    const SCEV *SrcCastOp = SrcCast->getOperand();
-    const SCEV *DstCastOp = DstCast->getOperand();
-    if (SrcCastOp->getType() == DstCastOp->getType()) {
-      Pair->Src = SrcCastOp;
-      Pair->Dst = DstCastOp;
-    }
-  }
-}
-
 // Examine the scev and return true iff it's affine.
 // Collect any loops mentioned in the set of "Loops".
 bool DependenceInfo::checkSubscript(const SCEV *Expr, const Loop *LoopNest,
@@ -3608,7 +3588,6 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
     Pair[P].Loops.resize(MaxLevels + 1);
     Pair[P].GroupLoops.resize(MaxLevels + 1);
     Pair[P].Group.resize(Pairs);
-    removeMatchingExtensions(&Pair[P]);
     Pair[P].Classification =
         classifyPair(Pair[P].Src, LI->getLoopFor(Src->getParent()), Pair[P].Dst,
                      LI->getLoopFor(Dst->getParent()), Pair[P].Loops);


        


More information about the llvm-commits mailing list