[llvm] [GlobalISel] port rewrite from SelectionDAG to GlobalISel (PR #181486)
Osman Yasar via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 14 09:39:44 PST 2026
================
@@ -1879,6 +1879,16 @@ def APlusBMinusCMinusB : GICombineRule<
(G_SUB $root, $add1, $B)),
(apply (G_SUB $root, $A, $C))>;
+// fold ((A+(B+C))-B) -> A+C
+def APlusBPlusCMinusB : GICombineRule<
+ (defs root:$root),
+ (match (G_ADD $add1, $B, $C),
+ (G_ADD $add2, $A, $add1),
+ (G_SUB $root, $add2, $B),
+ [{ return MRI.hasOneNonDBGUse(${add1}.getReg()) &&
+ MRI.hasOneNonDBGUse(${add2}.getReg()); }]),
+ (apply (G_ADD $root, $x, $n))>;
----------------
osmanyasar05 wrote:
```suggestion
(apply (G_ADD $root, $A, $C))>;
```
https://github.com/llvm/llvm-project/pull/181486
More information about the llvm-commits
mailing list