Skip to content

Commit 76ae9aa

Browse files
[CodeGen] Use range-based for loops (NFC) (#145251)
1 parent 6023ba2 commit 76ae9aa

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,9 +1700,9 @@ class ShuffleVectorSDNode : public SDNode {
17001700

17011701
static int getSplatMaskIndex(ArrayRef<int> Mask) {
17021702
assert(isSplatMask(Mask) && "Cannot get splat index for non-splat!");
1703-
for (unsigned i = 0, e = Mask.size(); i != e; ++i)
1704-
if (Mask[i] >= 0)
1705-
return Mask[i];
1703+
for (int Elem : Mask)
1704+
if (Elem >= 0)
1705+
return Elem;
17061706

17071707
// We can choose any index value here and be correct because all elements
17081708
// are undefined. Return 0 for better potential for callers to simplify.

llvm/lib/CodeGen/LiveInterval.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,8 @@ void LiveRangeUpdater::print(raw_ostream &OS) const {
11621162
for (const auto &S : make_range(LR->begin(), WriteI))
11631163
OS << ' ' << S;
11641164
OS << "\n Spills:";
1165-
for (unsigned I = 0, E = Spills.size(); I != E; ++I)
1166-
OS << ' ' << Spills[I];
1165+
for (const LiveRange::Segment &Spill : Spills)
1166+
OS << ' ' << Spill;
11671167
OS << "\n Area 2:";
11681168
for (const auto &S : make_range(ReadI, LR->end()))
11691169
OS << ' ' << S;

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19448,12 +19448,12 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
1944819448
std::swap(BasePtr, Offset);
1944919449

1945019450
// Replace other uses of BasePtr that can be updated to use Ptr
19451-
for (unsigned i = 0, e = OtherUses.size(); i != e; ++i) {
19451+
for (SDNode *OtherUse : OtherUses) {
1945219452
unsigned OffsetIdx = 1;
19453-
if (OtherUses[i]->getOperand(OffsetIdx).getNode() == BasePtr.getNode())
19453+
if (OtherUse->getOperand(OffsetIdx).getNode() == BasePtr.getNode())
1945419454
OffsetIdx = 0;
19455-
assert(OtherUses[i]->getOperand(!OffsetIdx).getNode() ==
19456-
BasePtr.getNode() && "Expected BasePtr operand");
19455+
assert(OtherUse->getOperand(!OffsetIdx).getNode() == BasePtr.getNode() &&
19456+
"Expected BasePtr operand");
1945719457

1945819458
// We need to replace ptr0 in the following expression:
1945919459
// x0 * offset0 + y0 * ptr0 = t0
@@ -19466,11 +19466,11 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
1946619466
// Therefore, we have:
1946719467
// t0 = (x0 * offset0 - x1 * y0 * y1 *offset1) + (y0 * y1) * t1
1946819468

19469-
auto *CN = cast<ConstantSDNode>(OtherUses[i]->getOperand(OffsetIdx));
19469+
auto *CN = cast<ConstantSDNode>(OtherUse->getOperand(OffsetIdx));
1947019470
const APInt &Offset0 = CN->getAPIntValue();
1947119471
const APInt &Offset1 = Offset->getAsAPIntVal();
19472-
int X0 = (OtherUses[i]->getOpcode() == ISD::SUB && OffsetIdx == 1) ? -1 : 1;
19473-
int Y0 = (OtherUses[i]->getOpcode() == ISD::SUB && OffsetIdx == 0) ? -1 : 1;
19472+
int X0 = (OtherUse->getOpcode() == ISD::SUB && OffsetIdx == 1) ? -1 : 1;
19473+
int Y0 = (OtherUse->getOpcode() == ISD::SUB && OffsetIdx == 0) ? -1 : 1;
1947419474
int X1 = (AM == ISD::PRE_DEC && !Swapped) ? -1 : 1;
1947519475
int Y1 = (AM == ISD::PRE_DEC && Swapped) ? -1 : 1;
1947619476

@@ -19481,17 +19481,16 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
1948119481
if (X1 * Y0 * Y1 < 0) CNV = CNV + Offset1;
1948219482
else CNV = CNV - Offset1;
1948319483

19484-
SDLoc DL(OtherUses[i]);
19484+
SDLoc DL(OtherUse);
1948519485

1948619486
// We can now generate the new expression.
1948719487
SDValue NewOp1 = DAG.getConstant(CNV, DL, CN->getValueType(0));
1948819488
SDValue NewOp2 = Result.getValue(IsLoad ? 1 : 0);
1948919489

19490-
SDValue NewUse = DAG.getNode(Opcode,
19491-
DL,
19492-
OtherUses[i]->getValueType(0), NewOp1, NewOp2);
19493-
DAG.ReplaceAllUsesOfValueWith(SDValue(OtherUses[i], 0), NewUse);
19494-
deleteAndRecombine(OtherUses[i]);
19490+
SDValue NewUse =
19491+
DAG.getNode(Opcode, DL, OtherUse->getValueType(0), NewOp1, NewOp2);
19492+
DAG.ReplaceAllUsesOfValueWith(SDValue(OtherUse, 0), NewUse);
19493+
deleteAndRecombine(OtherUse);
1949519494
}
1949619495

1949719496
// Replace the uses of Ptr with uses of the updated base value.

0 commit comments

Comments
 (0)