[llvm] [TableGen] HasOneUse builtin predicate on PatFrags (PR #91578)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 01:33:05 PDT 2024


================
@@ -468,7 +468,23 @@ bool GIMatchTableExecutor::executeMatchTable(
         if (handleReject() == RejectAndGiveUp)
           return false;
       }
+      break;
+    }
+    case GIM_CheckHasOneUse: {
+      uint64_t InsnID = readULEB();
 
+      DEBUG_WITH_TYPE(TgtExecutor::getName(),
+                      dbgs() << CurrentIdx << ": GIM_CheckHasOneUse(MIs["
+                             << InsnID << "]\n");
+
+      const MachineInstr *MI = State.MIs[InsnID];
+      assert(MI && "Used insn before defined");
+      assert(MI->getNumDefs() > 0 && "No defs");
+      const Register Res = MI->getOperand(0).getReg();
----------------
Pierre-vh wrote:

Yes, it depends on how many of these are emitted at once for a given pattern, we need to see more use first
Though this is just 2 bytes on average (1 byte opcode + 1 byte id) so it's not a big deal unless this is emitted in bulk in a ton of rules

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


More information about the llvm-commits mailing list