Skip to content

Commit 3c47fc4

Browse files
vladimirradosavljevicakiramenai
authored andcommitted
[EraVM] Refactor EraVMIndexedMemOpsPrepare::isValidGEPAndIncByOneCell
Refactor code to check whether BasePtr is increased by one cell per iteration. Signed-off-by: Vladimir Radosavljevic <[email protected]>
1 parent d4ed72c commit 3c47fc4

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

llvm/lib/Target/EraVM/EraVMIndexedMemOpsPrepare.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,14 @@ bool EraVMIndexedMemOpsPrepare::isValidGEPAndIncByOneCell(
184184
GetElementPtrInst *BasePtr) const {
185185
// Use SCEV info to check whether this BasePtr is increased
186186
// by one cell per iteration.
187-
const SCEV *SCEVPtr = SE->getSCEVAtScope(BasePtr, CurrentLoop);
188-
189-
if (SCEVPtr) {
190-
const auto *AddRec = dyn_cast<SCEVAddRecExpr>(SCEVPtr);
191-
if (!AddRec)
192-
return false;
193-
const auto *Step = dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
194-
if (!Step)
195-
return false;
196-
const APInt StrideVal = Step->getAPInt();
197-
if (StrideVal != 32)
198-
return false;
199-
}
187+
const auto *AddRec =
188+
dyn_cast<SCEVAddRecExpr>(SE->getSCEVAtScope(BasePtr, CurrentLoop));
189+
if (!AddRec)
190+
return false;
191+
192+
const auto *Step = dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
193+
if (!Step || Step->getAPInt() != 32)
194+
return false;
200195

201196
if (!std::all_of(
202197
BasePtr->op_begin(), std::prev(BasePtr->op_end()),

0 commit comments

Comments
 (0)