[llvm] [LAA] Improve code in replaceSymbolicStrideSCEV (NFC) (PR #139532)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 03:54:51 PDT 2025


https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/139532

Prefer DenseMap::lookup over DenseMap::find.

>From b98031fd009447e5b85454a5d54fc9188b7a0767 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 12 May 2025 11:47:51 +0100
Subject: [PATCH] [LAA] Improve code in replaceSymbolicStrideSCEV (NFC)

Prefer DenseMap::lookup over DenseMap::find.
---
 llvm/lib/Analysis/LoopAccessAnalysis.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 438669df51f89..f4e1d632b4d7d 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -158,12 +158,11 @@ const SCEV *llvm::replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
 
   // If there is an entry in the map return the SCEV of the pointer with the
   // symbolic stride replaced by one.
-  DenseMap<Value *, const SCEV *>::const_iterator SI = PtrToStride.find(Ptr);
-  if (SI == PtrToStride.end())
+  const SCEV *StrideSCEV = PtrToStride.lookup(Ptr);
+  if (!StrideSCEV)
     // For a non-symbolic stride, just return the original expression.
     return OrigSCEV;
 
-  const SCEV *StrideSCEV = SI->second;
   // Note: This assert is both overly strong and overly weak.  The actual
   // invariant here is that StrideSCEV should be loop invariant.  The only
   // such invariant strides we happen to speculate right now are unknowns



More information about the llvm-commits mailing list