Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 11a8423

Browse files
committed
[SCEV] Use reverse() (NFC)
1 parent c521288 commit 11a8423

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -2822,9 +2822,7 @@ static const SCEV *getExprBase(const SCEV *S) {
28222822
// there's nothing more complex.
28232823
// FIXME: not sure if we want to recognize negation.
28242824
const SCEVAddExpr *Add = cast<SCEVAddExpr>(S);
2825-
for (std::reverse_iterator<SCEVAddExpr::op_iterator> I(Add->op_end()),
2826-
E(Add->op_begin()); I != E; ++I) {
2827-
const SCEV *SubExpr = *I;
2825+
for (const SCEV *SubExpr : reverse(Add->operands())) {
28282826
if (SubExpr->getSCEVType() == scAddExpr)
28292827
return getExprBase(SubExpr);
28302828

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,8 @@ Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) {
747747
// so that pointer operands are inserted first, which the code below relies on
748748
// to form more involved GEPs.
749749
SmallVector<std::pair<const Loop *, const SCEV *>, 8> OpsAndLoops;
750-
for (std::reverse_iterator<SCEVAddExpr::op_iterator> I(S->op_end()),
751-
E(S->op_begin()); I != E; ++I)
752-
OpsAndLoops.push_back(std::make_pair(getRelevantLoop(*I), *I));
750+
for (const SCEV *Op : reverse(S->operands()))
751+
OpsAndLoops.push_back(std::make_pair(getRelevantLoop(Op), Op));
753752

754753
// Sort by loop. Use a stable sort so that constants follow non-constants and
755754
// pointer operands precede non-pointer operands.
@@ -811,9 +810,8 @@ Value *SCEVExpander::visitMulExpr(const SCEVMulExpr *S) {
811810
// Collect all the mul operands in a loop, along with their associated loops.
812811
// Iterate in reverse so that constants are emitted last, all else equal.
813812
SmallVector<std::pair<const Loop *, const SCEV *>, 8> OpsAndLoops;
814-
for (std::reverse_iterator<SCEVMulExpr::op_iterator> I(S->op_end()),
815-
E(S->op_begin()); I != E; ++I)
816-
OpsAndLoops.push_back(std::make_pair(getRelevantLoop(*I), *I));
813+
for (const SCEV *Op : reverse(S->operands()))
814+
OpsAndLoops.push_back(std::make_pair(getRelevantLoop(Op), Op));
817815

818816
// Sort by loop. Use a stable sort so that constants follow non-constants.
819817
llvm::stable_sort(OpsAndLoops, LoopCompare(SE.DT));

0 commit comments

Comments
 (0)