[llvm] [GlobalISel] Migrate remaining generic wip_match_opcode combines to MIR-pattern. (PR #222851)
Yaxun Liu via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 07:16:28 PDT 2026
================
@@ -1693,27 +1863,43 @@ def constant_fold_unary_int_op : GICombineRule<
[{ return Helper.matchConstantFoldUnaryIntOp(*${mi}, ${matchinfo}); }]),
(apply [{ Helper.applyBuildFn(*${mi}, ${matchinfo}); }])>;
-def mulo_by_2: GICombineRule<
- (defs root:$root, build_fn_matchinfo:$matchinfo),
- (match (wip_match_opcode G_UMULO, G_SMULO):$root,
- [{ return Helper.matchMulOBy2(*${root}, ${matchinfo}); }]),
- (apply [{ Helper.applyBuildFnNoErase(*${root}, ${matchinfo}); }])>;
-
-def mulo_by_0: GICombineRule<
+// G_UMULO/G_SMULO are two-def (result + carry) roots. A GICombinePatFrag root
+// must have a single root def, so instead each opcode is a per-opcode rule
+// (matching both defs structurally, like adde_to_addo) gathered under a group
+// keeping the original rule name.
+class mulo_by_2_rule<Instruction op, Instruction addo> : GICombineRule<
+ (defs root:$root),
+ (match (op $dst, $carry, $x, $rhs):$root,
+ [{ return Helper.matchConstantOp(${rhs}, 2); }]),
----------------
yxsamliu wrote:
The old matcher handled constants wider than 64 bits, but `matchConstantOp` rejects them. Could we keep the old APInt-based matching and add an `i128` test?
https://github.com/llvm/llvm-project/pull/222851
More information about the llvm-commits
mailing list