[llvm] [AArch64][GlobalISel] Add pre-legalizer combines for AVGFLOOR and AVGCEIL (PR #192866)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 09:54:44 PDT 2026
================
@@ -2300,6 +2300,70 @@ def overflow_combines: GICombineGroup<[
match_subo_no_overflow
]>;
+
+def avgfloor_u_match : GICombineRule<
+ (defs root:$dst, build_fn_matchinfo:$matchinfo),
+ (match (G_ZEXT $ext1, $x),
+ (G_ZEXT $ext2, $y),
+ (G_ADD $sum, $ext1, $ext2),
+ (G_LSHR $dst, $sum, 1):$mi,
+ [{ return Helper.matchAVG(*${mi}, MRI, /*IsSigned=*/false, /*IsCeil=*/false); }]),
+ (apply [{ Helper.applyAVG(B, *${mi}, ${x}.getReg(), ${y}.getReg(), /*IsSigned=*/false, /*IsCeil=*/false); }])
+>;
+
+def avgfloor_s_match : GICombineRule<
+ (defs root:$dst, build_fn_matchinfo:$matchinfo),
+ (match (G_SEXT $ext1, $x),
+ (G_SEXT $ext2, $y),
+ (G_ADD $sum, $ext1, $ext2),
+ (G_ASHR $dst, $sum, 1):$mi,
+ [{ return Helper.matchAVG(*${mi}, MRI, /*IsSigned=*/true, /*IsCeil=*/false); }]),
+ (apply [{ Helper.applyAVG(B, *${mi}, ${x}.getReg(), ${y}.getReg(), /*IsSigned=*/true, /*IsCeil=*/false); }])
+>;
+
+def avgceil_sum : GICombinePatFrag<
----------------
davemgreen wrote:
This one isn't used any more?
https://github.com/llvm/llvm-project/pull/192866
More information about the llvm-commits
mailing list