[llvm] [GlobalISel] Migrate various generic wip_match_opcode combines to MIR-pattern. (PR #220213)
Vikash Gupta via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 3 00:34:07 PDT 2026
================
@@ -448,11 +448,25 @@ def bitreverse_lshr : GICombineRule<
// Combine (shl (add x, c1), c2) -> (add (shl x, c2), c1 << c2)
// Combine (shl (or x, c1), c2) -> (or (shl x, c2), c1 << c2)
-def commute_shift : GICombineRule<
- (defs root:$d, build_fn_matchinfo:$matchinfo),
- (match (wip_match_opcode G_SHL):$d,
- [{ return Helper.matchCommuteShift(*${d}, ${matchinfo}); }]),
- (apply [{ Helper.applyBuildFn(*${d}, ${matchinfo}); }])>;
+// Apply rebuilds the matched opcode, so it stays inline C++. The builder is
+// used rather than an apply pattern so that (shl c1, c2) is constant folded.
----------------
vg0204 wrote:
As I going through Combine.td, I found it invokes matchConstantFoldBinOp that would do constant folding in next iteration, but it will need pre-requisite patch to support vector outputs, so I start working on that in parallel
https://github.com/llvm/llvm-project/pull/220213
More information about the llvm-commits
mailing list