[llvm] 430de48 - [GISel] Simplify getConstantVRegValWithLookThrough. NFC.

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 04:36:22 PST 2024


Author: Jay Foad
Date: 2024-03-08T12:26:43Z
New Revision: 430de48a61369ea41efe1cbb98654a86568ae95f

URL: https://github.com/llvm/llvm-project/commit/430de48a61369ea41efe1cbb98654a86568ae95f
DIFF: https://github.com/llvm/llvm-project/commit/430de48a61369ea41efe1cbb98654a86568ae95f.diff

LOG: [GISel] Simplify getConstantVRegValWithLookThrough. NFC.

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/Utils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 23ad68b331c977..a9fa73b60a097f 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -355,18 +355,17 @@ std::optional<ValueAndVReg> getConstantVRegValWithLookThrough(
   if (!MaybeVal)
     return std::nullopt;
   APInt &Val = *MaybeVal;
-  while (!SeenOpcodes.empty()) {
-    std::pair<unsigned, unsigned> OpcodeAndSize = SeenOpcodes.pop_back_val();
-    switch (OpcodeAndSize.first) {
+  for (auto [Opcode, Size] : reverse(SeenOpcodes)) {
+    switch (Opcode) {
     case TargetOpcode::G_TRUNC:
-      Val = Val.trunc(OpcodeAndSize.second);
+      Val = Val.trunc(Size);
       break;
     case TargetOpcode::G_ANYEXT:
     case TargetOpcode::G_SEXT:
-      Val = Val.sext(OpcodeAndSize.second);
+      Val = Val.sext(Size);
       break;
     case TargetOpcode::G_ZEXT:
-      Val = Val.zext(OpcodeAndSize.second);
+      Val = Val.zext(Size);
       break;
     }
   }


        


More information about the llvm-commits mailing list