[llvm] [GlobalISel] Migrate remaining generic wip_match_opcode combines to MIR-pattern. (PR #222851)

Vikash Gupta via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 03:40:10 PDT 2026


================
@@ -1785,15 +1988,18 @@ foreach fmaop = [G_FMAD, G_FMA] in {
 }
 
 def redundant_neg_operands : GICombineGroup<
-  [redundant_neg_operands_fadd_fsub, G_FMUL_fneg_fneg, G_FDIV_fneg_fneg,
+  [redundant_neg_operands_fadd_rhs, redundant_neg_operands_fadd_lhs,
+   redundant_neg_operands_fsub,
+   G_FMUL_fneg_fneg, G_FDIV_fneg_fneg,
    G_FMAD_fneg_fneg, G_FMA_fneg_fneg]>;
 
 // Transform (fsub +-0.0, X) -> (fneg X)
 def fsub_to_fneg: GICombineRule<
-  (defs root:$root, register_matchinfo:$matchinfo),
-  (match (G_FSUB $dst, $src1, $src2):$root,
-    [{ return Helper.matchFsubToFneg(*${root}, ${matchinfo}); }]),
-  (apply [{ Helper.applyFsubToFneg(*${root}, ${matchinfo}); }])>;
+  (defs root:$dst),
+  (match (G_FSUB $dst, $lhs, $rhs):$root,
----------------
vg0204 wrote:

I added a patch for now that skips `fsub_to_fneg` when both LHS and RHS are scalar constant (as vector binFP constant folding not supported yet), so `constant_fold_fp_binop` will eventually fold such cases.

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


More information about the llvm-commits mailing list