From e32b9eb32d7cd2d39bf9c70497890ac61b9ee14c Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 30 Nov 2021 09:52:25 +0000 Subject: vect: Add support for fmax and fmin reductions This patch adds support for reductions involving calls to fmax*() and fmin*(), without the -ffast-math flags that allow them to be converted to MAX_EXPR and MIN_EXPR. gcc/ * doc/md.texi (reduc_fmin_scal_@var{m}): Document. (reduc_fmax_scal_@var{m}): Likewise. * optabs.def (reduc_fmax_scal_optab): New optab. (reduc_fmin_scal_optab): Likewise * internal-fn.def (REDUC_FMAX, REDUC_FMIN): New functions. * tree-vect-loop.c (reduction_fn_for_scalar_code): Handle CASE_CFN_FMAX and CASE_CFN_FMIN. (neutral_op_for_reduction): Likewise. (needs_fold_left_reduction_p): Likewise. * config/aarch64/iterators.md (FMAXMINV): New iterator. (fmaxmin): Handle UNSPEC_FMAXNMV and UNSPEC_FMINNMV. * config/aarch64/aarch64-simd.md (reduc__scal_): Fix unspec mode. (reduc__scal_): New pattern. * config/aarch64/aarch64-sve.md (reduc__scal_): Likewise. gcc/testsuite/ * gcc.dg/vect/vect-fmax-1.c: New test. * gcc.dg/vect/vect-fmax-2.c: Likewise. * gcc.dg/vect/vect-fmax-3.c: Likewise. * gcc.dg/vect/vect-fmin-1.c: New test. * gcc.dg/vect/vect-fmin-2.c: Likewise. * gcc.dg/vect/vect-fmin-3.c: Likewise. * gcc.target/aarch64/fmaxnm_1.c: Likewise. * gcc.target/aarch64/fmaxnm_2.c: Likewise. * gcc.target/aarch64/fminnm_1.c: Likewise. * gcc.target/aarch64/fminnm_2.c: Likewise. * gcc.target/aarch64/sve/fmaxnm_2.c: Likewise. * gcc.target/aarch64/sve/fmaxnm_3.c: Likewise. * gcc.target/aarch64/sve/fminnm_2.c: Likewise. * gcc.target/aarch64/sve/fminnm_3.c: Likewise. --- gcc/doc/md.texi | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/doc/md.texi') diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 589f841..8fd0f8d 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -5400,6 +5400,14 @@ Find the unsigned minimum/maximum of the elements of a vector. The vector is operand 1, and operand 0 is the scalar result, with mode equal to the mode of the elements of the input vector. +@cindex @code{reduc_fmin_scal_@var{m}} instruction pattern +@cindex @code{reduc_fmax_scal_@var{m}} instruction pattern +@item @samp{reduc_fmin_scal_@var{m}}, @samp{reduc_fmax_scal_@var{m}} +Find the floating-point minimum/maximum of the elements of a vector, +using the same rules as @code{fmin@var{m}3} and @code{fmax@var{m}3}. +Operand 1 is a vector of mode @var{m} and operand 0 is the scalar +result, which has mode @code{GET_MODE_INNER (@var{m})}. + @cindex @code{reduc_plus_scal_@var{m}} instruction pattern @item @samp{reduc_plus_scal_@var{m}} Compute the sum of the elements of a vector. The vector is operand 1, and -- cgit v1.1