[llvm] [IVSimplify] Improve code in isLoopCounter (NFC) (PR #139533)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon May 12 04:18:24 PDT 2025
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/139533
None
>From 41b0308ab013fb8b07049665936a099445b920fb Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 12 May 2025 12:14:27 +0100
Subject: [PATCH] [IVSimplify] Improve code in isLoopCounter (NFC)
---
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 70610f7c020c8..f17ac9300c320 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -38,6 +38,7 @@
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/Analysis/ScalarEvolutionPatternMatch.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
@@ -53,7 +54,6 @@
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"
@@ -79,6 +79,7 @@
using namespace llvm;
using namespace PatternMatch;
+using namespace SCEVPatternMatch;
#define DEBUG_TYPE "indvars"
@@ -810,8 +811,7 @@ static bool isLoopCounter(PHINode* Phi, Loop *L,
if (!AR || AR->getLoop() != L || !AR->isAffine())
return false;
- const SCEV *Step = dyn_cast<SCEVConstant>(AR->getStepRecurrence(*SE));
- if (!Step || !Step->isOne())
+ if (!match(AR->getStepRecurrence(*SE), m_scev_SpecificInt(1)))
return false;
int LatchIdx = Phi->getBasicBlockIndex(L->getLoopLatch());
More information about the llvm-commits
mailing list