[llvm] [GIsel] import min/max rewrites (PR #188267)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 02:44:26 PDT 2026
================
@@ -2152,6 +2152,28 @@ def AMinusC1PlusC2: GICombineRule<
[{ return Helper.matchFoldAMinusC1PlusC2(*${root}, ${matchinfo}); }]),
(apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
+// (sub 0, (max X, (sub 0, X))) --> (min X, (sub 0, X))
+def SubSmaxSub: GICombineRule<
+ (defs root:$root),
+ (match (G_SUB $sub, 0, $A),
+ (G_SMAX $max, $A, $sub),
+ (G_SUB $root, 0, $max),
+ [{ return MRI.hasOneNonDBGUse(${sub}.getReg()) &&
+ MRI.hasOneNonDBGUse(${max}.getReg()); }]),
+ (apply (G_SUB $sub1, 0, $A),
+ (G_SMIN $root, $A, $sub1))>;
+
----------------
davemgreen wrote:
Can you remove the whitespace?
https://github.com/llvm/llvm-project/pull/188267
More information about the llvm-commits
mailing list