[llvm] LAA: improve code in getStrideFromPointer (NFC) (PR #124780)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 01:48:27 PST 2025
================
@@ -2888,25 +2885,19 @@ static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *L
return nullptr;
V = S->getStepRecurrence(*SE);
- if (!V)
- return nullptr;
// Strip off the size of access multiplication if we are still analyzing the
// pointer.
if (OrigPtr == Ptr) {
- if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(V)) {
- if (M->getOperand(0)->getSCEVType() != scConstant)
+ if (auto *M = dyn_cast<SCEVMulExpr>(V)) {
+ auto *StepConst = dyn_cast<SCEVConstant>(M->getOperand(0));
+ if (!StepConst)
return nullptr;
- const APInt &APStepVal = cast<SCEVConstant>(M->getOperand(0))->getAPInt();
-
- // Huge step value - give up.
- if (APStepVal.getBitWidth() > 64)
+ if (auto StepVal = StepConst->getAPInt().trySExtValue();
+ !StepVal || StepVal != 1)
----------------
david-arm wrote:
`trySExtValue` returns std::optional<int64_t> so I don't know what `StepVal != 1` is actually testing here. I think you can just drop it.
https://github.com/llvm/llvm-project/pull/124780
More information about the llvm-commits
mailing list