[llvm] [SCEV] Simplify getElementSz using getLoadStore-helpers (NFC) (PR #222908)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 03:58:32 PDT 2026
https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/222908
>From 7d9996453c564fa2b7636c12441e803a04ded0ef Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Fri, 11 Sep 2026 11:07:41 +0100
Subject: [PATCH 1/2] [SCEV] Simplify getElementSz using getLoadStore-helpers
(NFC)
---
llvm/lib/Analysis/ScalarEvolution.cpp | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 689a8741af983..f8d64db0e67ff 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -14042,20 +14042,12 @@ 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 *Ty = getLoadStoreType(Inst);
+ Type *PtrTy =
+ getEffectiveSCEVType(getLoadStorePointerOperand(Inst)->getType());
+ return getSizeOfExpr(PtrTy, Ty);
}
//===----------------------------------------------------------------------===//
>From 5ed9564af30ea1219a537e0f3be4e426328653cc Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Tue, 15 Sep 2026 11:51:51 +0100
Subject: [PATCH 2/2] [SCEV] Apply suggestions from review
---
llvm/lib/Analysis/ScalarEvolution.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index f8d64db0e67ff..4de996a8c5cf8 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -14044,10 +14044,8 @@ bool ScalarEvolution::containsErasedValue(const SCEV *S) const {
const SCEV *ScalarEvolution::getElementSize(Instruction *Inst) {
if (!isa<LoadInst, StoreInst>(Inst))
return nullptr;
- Type *Ty = getLoadStoreType(Inst);
- Type *PtrTy =
- getEffectiveSCEVType(getLoadStorePointerOperand(Inst)->getType());
- return getSizeOfExpr(PtrTy, Ty);
+ Type *ETy = getEffectiveSCEVType(getLoadStorePointerOperand(Inst)->getType());
+ return getSizeOfExpr(ETy, getLoadStoreType(Inst));
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list