[llvm] [AMDGPU][GISel] Fold 'min(min(x,y),z)' and 'max(max(x,y),z)' into min3 and max3 (PR #124263)

Alan Li via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 07:59:30 PST 2025


================
@@ -71,6 +71,16 @@ def int_minmax_to_med3 : GICombineRule<
          [{ return matchIntMinMaxToMed3(*${min_or_max}, ${matchinfo}); }]),
   (apply [{ applyMed3(*${min_or_max}, ${matchinfo}); }])>;
 
+def minmax3_matchdata : GIDefMatchData<"VOP3MatchInfo">;
+
+def minmax_to_minmax3
+    : GICombineRule<
+          (defs root:$min_or_max, minmax3_matchdata:$matchinfo),
+          (match(wip_match_opcode G_SMAX, G_SMIN, G_UMAX, G_UMIN, G_FMAXNUM,
----------------
lialan wrote:

See this: https://github.com/llvm/llvm-project/blob/main/llvm/docs/GlobalISel/MIRPatterns.rst#gallery

Can avoid using `wip_match_opcode`.

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


More information about the llvm-commits mailing list