[llvm] fe69e13 - [SCEV] Simplify getElementSz using getLoadStore-helpers (NFC) (#222908)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 04:52:28 PDT 2026


Author: Ramkumar Ramachandra
Date: 2026-09-15T11:52:22Z
New Revision: fe69e138ee0ed61b69ea2de846d550798fe69e2e

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

LOG: [SCEV] Simplify getElementSz using getLoadStore-helpers (NFC) (#222908)

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 689a8741af983..4de996a8c5cf8 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -14042,20 +14042,10 @@ bool ScalarEvolution::containsErasedValue(const SCEV *S) const {
 
 /// Return the size of an element read or written by Inst.
 const SCEV *ScalarEvolution::getElementSize(Instruction *Inst) {
-  Type *Ty;
-  Type *PtrTy;
-  if (StoreInst *Store = dyn_cast<StoreInst>(Inst)) {
-    Ty = Store->getValueOperand()->getType();
-    PtrTy = Store->getPointerOperandType();
-  } else if (LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
-    Ty = Load->getType();
-    PtrTy = Load->getPointerOperandType();
-  } else {
+  if (!isa<LoadInst, StoreInst>(Inst))
     return nullptr;
-  }
-
-  Type *ETy = getEffectiveSCEVType(PtrTy);
-  return getSizeOfExpr(ETy, Ty);
+  Type *ETy = getEffectiveSCEVType(getLoadStorePointerOperand(Inst)->getType());
+  return getSizeOfExpr(ETy, getLoadStoreType(Inst));
 }
 
 //===----------------------------------------------------------------------===//


        


More information about the llvm-commits mailing list