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

Deepak Shirke via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 06:50:52 PDT 2026


================
@@ -2234,6 +2229,9 @@ bool CombineRuleBuilder::emitCodeGenInstructionMatchPattern(
   IM.addPredicate<InstructionOpcodeMatcher>(&P.getInst());
   declareInstExpansion(CE, IM, P.getName());
 
+  if (P.hasOneUse())
+    IM.addPredicate<OneUsePredicateMatcher>();
----------------
deepakshirkem wrote:

OneUsePredicateMatcher was already implemented in GlobalISel/MatchTable/Matchers.h and used by GlobalISelEmitter.cpp for SelectionDAG instruction selection patterns. Similarly, GIM_CheckHasOneUse was already in the executor (GIMatchTableExecutorImpl.h) but was never emitted by the combiner emitter before this patch.

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


More information about the llvm-commits mailing list