[llvm] [GIsel] import `(not (add X, -1)) -> (neg X)` to GlobalISel (PR #181640)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 19 12:14:46 PST 2026


================
@@ -1946,6 +1946,14 @@ def APlusBMinusCPlusA : GICombineRule<
           (G_SUB $sub1, $B, $add1),
           (G_ADD $root, $A, $sub1)),
    (apply (G_SUB $root, $B, $C))>;
+   
+// fold (not (add X, -1)) -> (sub 0, X)
+def NotAPlusNegOne: GICombineRule<
+   (defs root:$root),
+   (match (G_ADD $add, $A, -1),
+          (G_XOR $root, $add, -1),
+          [{ return MRI.hasOneNonDBGUse(${add}.getReg()); }]),
----------------
arsenm wrote:

We really need to get a proper way of doing this inline 

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


More information about the llvm-commits mailing list