[llvm] [LLVM][TableGen] Code cleanup in FastISelEmitter.cpp (PR #139644)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 09:57:17 PDT 2025


================
@@ -151,48 +148,42 @@ struct OperandsSignature {
   bool empty() const { return Operands.empty(); }
 
   bool hasAnyImmediateCodes() const {
-    for (unsigned i = 0, e = Operands.size(); i != e; ++i)
-      if (Operands[i].isImm() && Operands[i].getImmCode() != 0)
-        return true;
-    return false;
+    return llvm::any_of(Operands, [](OpKind Kind) {
+      return Kind.isImm() && Kind.getImmCode() != 0;
+    });
   }
 
   /// getWithoutImmCodes - Return a copy of this with any immediate codes forced
   /// to zero.
   OperandsSignature getWithoutImmCodes() const {
     OperandsSignature Result;
-    for (unsigned i = 0, e = Operands.size(); i != e; ++i)
-      if (!Operands[i].isImm())
-        Result.Operands.push_back(Operands[i]);
-      else
-        Result.Operands.push_back(OpKind::getImm(0));
+    Result.Operands.resize(Operands.size());
+    for (auto [RO, O] : zip_equal(Result.Operands, Operands))
+      RO = O.isImm() ? OpKind::getImm(0) : O;
----------------
jurahul wrote:

Done.

https://github.com/llvm/llvm-project/pull/139644


More information about the llvm-commits mailing list