public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: YunQiang Su <yunqiang.su@cipunited.com>
To: gcc-patches@gcc.gnu.org
Cc: YunQiang Su <yunqiang.su@cipunited.com>
Subject: [committed] MIPS: Use -mnan value for -mabs if not specified
Date: Thu,  9 Nov 2023 18:30:36 +0800	[thread overview]
Message-ID: <20231109103037.281290-1-yunqiang.su@cipunited.com> (raw)

On most hardware, FCSR.ABS2008 is set the value same with FCSR.NAN2008.
Let's use this behaivor by default in GCC, aka
	gcc -mnan=2008 -c fabs.c
will imply `-mabs=2008`.

And of course, `gcc -mnan=2008 -mabs=legacy` can continue workable
like previous.

gcc/ChangeLog

	* config/mips/mips.cc(mips_option_override): Set mips_abs to
	2008, if mips_abs is default and mips_nan is 2008.

gcc/testsuite/
	* gcc.target/mips/fabs-nan2008.c: New test.
	* gcc.target/mips/fabsf-nan2008.c: New test.
---
 gcc/config/mips/mips.cc                       |  2 ++
 gcc/testsuite/gcc.target/mips/fabs-nan2008.c  | 10 ++++++++++
 gcc/testsuite/gcc.target/mips/fabsf-nan2008.c | 10 ++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/mips/fabs-nan2008.c
 create mode 100644 gcc/testsuite/gcc.target/mips/fabsf-nan2008.c

diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index a304e1c5637..cbd7d9bb284 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -20550,6 +20550,8 @@ mips_option_override (void)
   /* Set NaN and ABS defaults.  */
   if (mips_nan == MIPS_IEEE_754_DEFAULT && !ISA_HAS_IEEE_754_LEGACY)
     mips_nan = MIPS_IEEE_754_2008;
+  if (mips_abs == MIPS_IEEE_754_DEFAULT && mips_nan == MIPS_IEEE_754_2008)
+    mips_abs = MIPS_IEEE_754_2008;
   if (mips_abs == MIPS_IEEE_754_DEFAULT && !ISA_HAS_IEEE_754_LEGACY)
     mips_abs = MIPS_IEEE_754_2008;
 
diff --git a/gcc/testsuite/gcc.target/mips/fabs-nan2008.c b/gcc/testsuite/gcc.target/mips/fabs-nan2008.c
new file mode 100644
index 00000000000..9e2719bbf36
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fabs-nan2008.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=2008" } */
+
+NOMIPS16 double
+fabs_2008 (double d)
+{
+  return __builtin_fabs (d);
+}
+
+/* { dg-final { scan-assembler "\tabs\\.d\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fabsf-nan2008.c b/gcc/testsuite/gcc.target/mips/fabsf-nan2008.c
new file mode 100644
index 00000000000..11c423429d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fabsf-nan2008.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=2008" } */
+
+NOMIPS16 float
+fabsf_2008 (float f)
+{
+  return __builtin_fabsf (f);
+}
+
+/* { dg-final { scan-assembler "\tabs\\.s\t" } } */
-- 
2.39.2


                 reply	other threads:[~2023-11-09 10:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231109103037.281290-1-yunqiang.su@cipunited.com \
    --to=yunqiang.su@cipunited.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).