[llvm] [LLVM][AArch64][tblgen]: Match clamp pattern (PR #75529)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 04:02:25 PST 2023
================
@@ -4054,10 +4050,36 @@ defm BFMAXNM_ZPZZ : sve2p1_bf_bin_pred_zds<AArch64fmaxnm_p>;
defm BFMINNM_ZPZZ : sve2p1_bf_bin_pred_zds<AArch64fminnm_p>;
defm BFMUL_ZZZI : sve2p1_fp_bfmul_by_indexed_elem<"bfmul", int_aarch64_sve_fmul_lane>;
-
-defm BFCLAMP_ZZZ : sve2p1_bfclamp<"bfclamp", int_aarch64_sve_fclamp>;
} // End HasSVE2p1_or_HasSME2p1, HasB16B16
+// Replace pattern min(max(v1,v2),v3) by clamp
+def clamp_min_max : PatFrags<(ops node:$Zd, node:$Zn, node:$Zm),
+ [(AArch64smin_p (SVEAllActive),
+ (AArch64smax_p (SVEAllActive), node:$Zd, node:$Zn),
+ node:$Zm),
+ (AArch64fmin_p (SVEAllActive),
+ (AArch64fmax_p (SVEAllActive), node:$Zd, node:$Zn),
+ node:$Zm)
+ ]>;
+def uclamp_min_max : PatFrag<(ops node:$Zd, node:$Zn, node:$Zm),
+ (AArch64umin_p (SVEAllActive),
+ (AArch64umax_p (SVEAllActive), node:$Zd, node:$Zn),
+ node:$Zm)>;
+def bfclamp_min_max : PatFrag<(ops node:$pg, node:$Zd, node:$Zn, node:$Zm),
+ (int_aarch64_sve_fmin node:$pg,
+ (nxv8bf16 (int_aarch64_sve_fmax node:$pg, node:$Zd, node:$Zn)),
----------------
paulwalker-arm wrote:
Sorry I should have been clearer here. Given you're forced to hardwire the type here you may as well hardwire the predicate as well (i.e. use `(nxv8i1 (SVEAllActive))` that way you can define a `bfclamp` PatFrag which also include the intrinsic.
https://github.com/llvm/llvm-project/pull/75529
More information about the llvm-commits
mailing list