[llvm] [GlobalISel] Add GIHasOneUse builtin for combiner match patterns (PR #221804)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 05:18:43 PDT 2026


================
@@ -69,6 +69,29 @@ bool PatternParser::parsePatternList(
       continue;
     }
 
+    if (const auto *DagArg = dyn_cast<DagInit>(Arg)) {
+      if (DagArg->getOperatorAsDef(DiagLoc)->getName() == "GIHasOneUse") {
+        if (DagArg->getNumArgs() != 1) {
+          PrintError(DiagLoc,
+                     "GIHasOneUse expects exactly one instruction argument");
+          return false;
+        }
+        if (auto Pat = parseInstructionPattern(*DagArg->getArg(0), Name)) {
+          if (auto *CGP = dyn_cast<CodeGenInstructionPattern>(Pat.get()))
+            CGP->setHasOneUse();
+          else {
+            PrintError(
+                DiagLoc,
+                "GIHasOneUse can only wrap a CodeGenInstruction pattern");
----------------
arsenm wrote:

Missing error case tests 

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


More information about the llvm-commits mailing list