[llvm] Check Affine AR only. (PR #144550)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 08:52:49 PDT 2025


https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/144550

None

>From a84bda8153b33ae04d89c01ae59cf03c193705d5 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Tue, 17 Jun 2025 16:51:19 +0100
Subject: [PATCH] Check Affine AR only.

---
 llvm/lib/Analysis/ScalarEvolution.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index dd309bc2c54a8..a919425df5db4 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -10894,9 +10894,7 @@ bool ScalarEvolution::SimplifyICmpOperands(CmpPredicate &Pred, const SCEV *&LHS,
   case ICmpInst::ICMP_UGE:
     // If RHS is an op we can fold the -1, try that first.
     // Otherwise prefer LHS to preserve the nuw flag.
-    if ((isa<SCEVConstant>(RHS) ||
-         (isa<SCEVAddExpr, SCEVAddRecExpr>(RHS) &&
-          isa<SCEVConstant>(cast<SCEVNAryExpr>(RHS)->getOperand(0)))) &&
+    if ((isa<SCEVConstant>(RHS) || match(RHS, m_scev_AffineAddRec(m_SCEVConstant(), m_SCEV(), m_Loop()))) &&
         !getUnsignedRangeMin(RHS).isMinValue()) {
       RHS = getAddExpr(getConstant(RHS->getType(), (uint64_t)-1, true), RHS);
       Pred = ICmpInst::ICMP_UGT;



More information about the llvm-commits mailing list