Skip to content

Commit a9a4e1f

Browse files
committed
LAA: combine loops
1 parent c802dc2 commit a9a4e1f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,16 +2815,17 @@ static Value *getLoopVariantGEPOperand(Value *Ptr, ScalarEvolution *SE,
28152815
if (!GEP)
28162816
return Ptr;
28172817

2818-
// There must be exactly one loop-variant operand.
2819-
if (count_if(GEP->operands(), [&](const Use &U) {
2820-
return !SE->isLoopInvariant(SE->getSCEV(U), Lp);
2821-
}) != 1)
2822-
return Ptr;
2823-
2824-
auto *It = find_if(GEP->operands(), [&](const Use &U) {
2825-
return !SE->isLoopInvariant(SE->getSCEV(U), Lp);
2826-
});
2827-
return It->get();
2818+
Value *V = Ptr;
2819+
for (const Use &U : GEP->operands()) {
2820+
if (!SE->isLoopInvariant(SE->getSCEV(U), Lp)) {
2821+
if (V == Ptr)
2822+
V = U;
2823+
else
2824+
// There must be exactly one loop-variant operand.
2825+
return Ptr;
2826+
}
2827+
}
2828+
return V;
28282829
}
28292830

28302831
/// Get the stride of a pointer access in a loop. Looks for symbolic

0 commit comments

Comments
 (0)