Skip to content

Commit ed570ac

Browse files
committed
Address review comments
* Change struct -> class. * Update comments about outside users of loop instructions. * In same loop as ^^ remove the check for IndPhi as this was unnecessary. * Fix formatting issue.
1 parent e03615a commit ed570ac

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

llvm/lib/Target/AArch64/AArch64LoopIdiomTransform.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ AArch64LoopIdiomTransformPass::run(Loop &L, LoopAnalysisManager &AM,
180180
//
181181
//===----------------------------------------------------------------------===//
182182

183-
struct MemCompareIdiom {
183+
class MemCompareIdiom {
184184
private:
185185
const TargetTransformInfo *TTI;
186186
DominatorTree *DT;
@@ -199,7 +199,7 @@ struct MemCompareIdiom {
199199
LoopInfo *LI, Loop *L)
200200
: TTI(TTI), DT(DT), LI(LI), CurLoop(L) {}
201201

202-
bool recognize();
202+
bool recognizeMemCompare();
203203
void transform();
204204

205205
private:
@@ -228,7 +228,7 @@ bool AArch64LoopIdiomTransform::run(Loop *L) {
228228
<< "] Loop %" << CurLoop->getHeader()->getName() << "\n");
229229

230230
MemCompareIdiom BCI(TTI, DT, LI, L);
231-
if (BCI.recognize()) {
231+
if (BCI.recognizeMemCompare()) {
232232
BCI.transform();
233233
return true;
234234
}
@@ -346,8 +346,7 @@ bool MemCompareIdiom::checkEndAndFoundBlockPhis(Value *IndVal) {
346346
// same as the end value (MaxLen) so we permit either. Otherwise for any
347347
// other value defined outside the loop we only allow values that are the
348348
// same as the exit value for while.body.
349-
if (V1 != V2 &&
350-
((V1 != IndVal && V1 != MaxLen) || (V2 != IndVal)))
349+
if (V1 != V2 && ((V1 != IndVal && V1 != MaxLen) || (V2 != IndVal)))
351350
return false;
352351
}
353352
}
@@ -399,7 +398,7 @@ bool MemCompareIdiom::recognizePostIncMemCompare() {
399398
return true;
400399
}
401400

402-
bool MemCompareIdiom::recognize() {
401+
bool MemCompareIdiom::recognizeMemCompare() {
403402
// Currently the transformation only works on scalable vector types, although
404403
// there is no fundamental reason why it cannot be made to work for fixed
405404
// width too.
@@ -437,12 +436,12 @@ bool MemCompareIdiom::recognize() {
437436
!match(Index, m_c_Add(m_Specific(IndPhi), m_One())))
438437
return false;
439438

440-
// If we match the pattern, IndPhi and Index will be replaced with the result
441-
// of the mismatch. If any other instructions are used outside of the loop, we
442-
// cannot replace it.
439+
// If we match the pattern, for the post-inc loop Index will be replaced
440+
// with the value returned from generateMemCompare. If any other
441+
// instructions are used outside of the loop, we cannot replace it.
443442
for (BasicBlock *BB : CurLoop->getBlocks())
444443
for (Instruction &I : *BB)
445-
if (&I != IndPhi && &I != Index)
444+
if (&I != Index)
446445
for (User *U : I.users())
447446
if (!CurLoop->contains(cast<Instruction>(U)))
448447
return false;

0 commit comments

Comments
 (0)