[llvm] LAA: improve code in getStrideFromPointer (NFC) (PR #124780)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 03:46:14 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)
return nullptr;
- int64_t StepVal = APStepVal.getSExtValue();
- if (PtrAccessSize != StepVal)
----------------
david-arm wrote:
OK I see that `PtrAccessSize` seems to be always set to 1. It wasn't immediately obvious to me that this was a fixed value. In that case, shouldn't this be `*StepVal != 1`? It's an optional value so you have to dereference it.
https://github.com/llvm/llvm-project/pull/124780
More information about the llvm-commits
mailing list