public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: chenxiaolong <chenxiaolong@loongson.cn>
Cc: gcc-patches@gcc.gnu.org,  xry111@xry111.site,  i@xen0n.name,
	 xuchenghua@loongson.cn,  chenglulu@loongson.cn
Subject: Re: [PATCH v1] LoongArch: testsuite:Add the "-ffast-math" compilation option for the file vect-fmin-3.c.
Date: Sat, 30 Dec 2023 12:15:25 +0000	[thread overview]
Message-ID: <mpth6jzevj6.fsf@arm.com> (raw)
In-Reply-To: <20231229040015.6275-1-chenxiaolong@loongson.cn> (chenxiaolong@loongson.cn's message of "Fri, 29 Dec 2023 12:00:15 +0800")

chenxiaolong <chenxiaolong@loongson.cn> writes:
> After the detection of maximum reduction is enabled on LoongArch architecture,
> the regression test of GCC finds that vect-fmin-3.c fails. Currently, in the
> target-supports.exp file, only aarch64,arm,riscv, and LoongArch architectures
> are supported. Through analysis, the "-ffast-math" compilation option needs to
> be added to the test case in order to successfully reduce using vectorization.
> The original patch was submitted by author Richard Sandiford.
>
> The initial patch information submitted is as follows:
>
> commit e32b9eb32d7cd2d39bf9c70497890ac61b9ee14c
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.dg/vect/vect-fmin-3.c:Adding an extra "-ffast-math" to the
>         compilation option ensures that the loop can be reduced to maximum
>         success.

This shouldn't be necessary.  The test does:

  for (int i = 0; i < n; i += 2)
    {
      x0 = __builtin_fmin (x0, ptr[i + 0]);
      x1 = __builtin_fmin (x1, ptr[i + 1]);
    }
  res[0] = x0;
  res[1] = x1;

__builtin_fmin is an FP minimum operation that corresponds directly to
the fmin*3 optab (or reduc_fmin_scal_* for reductions).  It is naturally
associative, so doesn't need -ffast-math for that.

Does LoongArch provide reduc_min_scal_* but not reduc_fmin_scal_*?
If so, we probably need a new target selector for fmin/fmax reduction.

Thanks,
Richard


> ---
>  gcc/testsuite/gcc.dg/vect/vect-fmin-3.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gcc/testsuite/gcc.dg/vect/vect-fmin-3.c b/gcc/testsuite/gcc.dg/vect/vect-fmin-3.c
> index 2e282ba6878..edef57925c1 100644
> --- a/gcc/testsuite/gcc.dg/vect/vect-fmin-3.c
> +++ b/gcc/testsuite/gcc.dg/vect/vect-fmin-3.c
> @@ -1,4 +1,5 @@
>  /* { dg-require-effective-target vect_float } */
> +/* { dg-additional-options "-ffast-math" } */
>  
>  #include "tree-vect.h"

  reply	other threads:[~2023-12-30 12:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29  4:00 chenxiaolong
2023-12-30 12:15 ` Richard Sandiford [this message]
2023-12-30 12:25   ` Xi Ruoyao
2023-12-30 12:39     ` Xi Ruoyao
2023-12-30 12:45     ` chenglulu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mpth6jzevj6.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=chenglulu@loongson.cn \
    --cc=chenxiaolong@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).