[llvm] [SCEV] Simplify getElementSz using getLoadStore-helpers (NFC) (PR #222908)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 03:14:33 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/222908.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+5-13)
``````````diff
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 06f350fd2179b..85ee3848cbb5b 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -14026,20 +14026,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);
}
//===----------------------------------------------------------------------===//
``````````
</details>
https://github.com/llvm/llvm-project/pull/222908
More information about the llvm-commits
mailing list