[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:16:54 PDT 2026
================
@@ -0,0 +1,21 @@
+// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
+// RUN: -combiners=MyCombiner %s | \
+// RUN: FileCheck %s
+
+include "llvm/Target/Target.td"
+include "llvm/Target/GlobalISel/Combine.td"
+
+def MyTargetISA : InstrInfo;
+def MyTarget : Target { let InstructionSet = MyTargetISA; }
+
+// CHECK: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_MUL)
+// CHECK: GIM_CheckHasOneUse, /*MI*/1
+def test_has_one_use: GICombineRule<
+ (defs root:$d),
+ (match (G_MUL $mul, $x, $c),
+ (G_SUB $d, $a, $mul),
+ (GIHasOneUse $mul)),
+ (apply (GIReplaceReg $d, $x))
+>;
+
----------------
arsenm wrote:
Do both methods work? If so test both?
https://github.com/llvm/llvm-project/pull/221804
More information about the llvm-commits
mailing list