Skip to content

Commit 430de48

Browse files
committed
[GISel] Simplify getConstantVRegValWithLookThrough. NFC.
1 parent 5d98d88 commit 430de48

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,18 +355,17 @@ std::optional<ValueAndVReg> getConstantVRegValWithLookThrough(
355355
if (!MaybeVal)
356356
return std::nullopt;
357357
APInt &Val = *MaybeVal;
358-
while (!SeenOpcodes.empty()) {
359-
std::pair<unsigned, unsigned> OpcodeAndSize = SeenOpcodes.pop_back_val();
360-
switch (OpcodeAndSize.first) {
358+
for (auto [Opcode, Size] : reverse(SeenOpcodes)) {
359+
switch (Opcode) {
361360
case TargetOpcode::G_TRUNC:
362-
Val = Val.trunc(OpcodeAndSize.second);
361+
Val = Val.trunc(Size);
363362
break;
364363
case TargetOpcode::G_ANYEXT:
365364
case TargetOpcode::G_SEXT:
366-
Val = Val.sext(OpcodeAndSize.second);
365+
Val = Val.sext(Size);
367366
break;
368367
case TargetOpcode::G_ZEXT:
369-
Val = Val.zext(OpcodeAndSize.second);
368+
Val = Val.zext(Size);
370369
break;
371370
}
372371
}

0 commit comments

Comments
 (0)