[llvm] [LAA] Simplify GEP SCEV in findForkedSCEVs (NFC) (PR #140384)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 17 10:41:54 PDT 2025
llvmbot 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/140384.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/LoopAccessAnalysis.cpp (+7-14)
``````````diff
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index ab407e945bc53..58083cb06f5f6 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -999,23 +999,16 @@ static void findForkedSCEVs(
break;
}
- // Find the pointer type we need to extend to.
- Type *IntPtrTy = SE->getEffectiveSCEVType(
- SE->getSCEV(GEP->getPointerOperand())->getType());
-
- // Find the size of the type being pointed to. We only have a single
- // index term (guarded above) so we don't need to index into arrays or
- // structures, just get the size of the scalar value.
- const SCEV *Size = SE->getSizeOfExpr(IntPtrTy, SourceTy);
-
// Scale up the offsets by the size of the type, then add to the bases.
+ const SCEV *Offset0 = get<0>(OffsetScevs[0]);
+ const SCEV *Offset1 = get<0>(OffsetScevs[1]);
+ const SCEV *Scaled0 = SE->getMulExpr(
+ SE->getSizeOfExpr(Offset0->getType(), SourceTy), Offset0);
const SCEV *Scaled1 = SE->getMulExpr(
- Size, SE->getTruncateOrSignExtend(get<0>(OffsetScevs[0]), IntPtrTy));
- const SCEV *Scaled2 = SE->getMulExpr(
- Size, SE->getTruncateOrSignExtend(get<0>(OffsetScevs[1]), IntPtrTy));
- ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[0]), Scaled1),
+ SE->getSizeOfExpr(Offset1->getType(), SourceTy), Offset1);
+ ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[0]), Scaled0),
NeedsFreeze);
- ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[1]), Scaled2),
+ ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[1]), Scaled1),
NeedsFreeze);
break;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/140384
More information about the llvm-commits
mailing list