[llvm] [polly] [SCEV] Introduce SDiv expressions (PR #216862)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 01:48:36 PDT 2026


================
@@ -13060,74 +13122,67 @@ bool ScalarEvolution::isImpliedViaOperations(CmpPredicate Pred, const SCEV *LHS,
     // (LHS = LL + LR) && (LR >= 0) && (LL > RHS) => (LHS > RHS).
     if (IsSumGreaterThanRHS(LL, LR) || IsSumGreaterThanRHS(LR, LL))
       return true;
-  } else if (auto *LHSUnknownExpr = dyn_cast<SCEVUnknown>(LHS)) {
-    Value *LL, *LR;
-    // FIXME: Once we have SDiv implemented, we can get rid of this matching.
-
-    using namespace llvm::PatternMatch;
-
-    if (match(LHSUnknownExpr->getValue(), m_SDiv(m_Value(LL), m_Value(LR)))) {
-      // Rules for division.
-      // We are going to perform some comparisons with Denominator and its
-      // derivative expressions. In general case, creating a SCEV for it may
-      // lead to a complex analysis of the entire graph, and in particular it
-      // can request trip count recalculation for the same loop. This would
-      // cache as SCEVCouldNotCompute to avoid the infinite recursion. To avoid
-      // this, we only want to create SCEVs that are constants in this section.
-      // So we bail if Denominator is not a constant.
-      if (!isa<ConstantInt>(LR))
-        return false;
+  } else if (auto *LHSSDivExpr = dyn_cast<SCEVSDivExpr>(LHS)) {
+    SCEVUse LL = LHSSDivExpr->getOperand(0);
+    SCEVUse LR = LHSSDivExpr->getOperand(0);
----------------
artagnon wrote:

Thanks! :)

https://github.com/llvm/llvm-project/pull/216862


More information about the llvm-commits mailing list