public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] fegetenv_and_set_rn now uses the builtins provided by GCC.
Date: Wed, 27 Sep 2023 16:57:35 +0000 (GMT)	[thread overview]
Message-ID: <20230927165735.27AA83857726@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4eac1825ed92e88c192abb436412d5fb84ddd854

commit 4eac1825ed92e88c192abb436412d5fb84ddd854
Author: Manjunath Matti <mmatti@linux.ibm.com>
Date:   Sat Sep 23 10:49:51 2023 -0500

    fegetenv_and_set_rn now uses the builtins provided by GCC.
    
    On powerpc, SET_RESTORE_ROUND uses inline assembly to optimize the
    prologue get/save/set rounding mode operations for POWER9 and
    later by using 'mffscrn' where possible, this was introduced by
    commit f1c56cdff09f650ad721fae026eb6a3651631f3d.
    
    GCC version 14 onwards supports builtins as __builtin_set_fpscr_rn
    which now returns the FPSCR fields in a double. This feature is
    available on Power9 when the __SET_FPSCR_RN_RETURNS_FPSCR__ macro
    is defined.
    GCC commit ef3bbc69d15707e4db6e2f198c621effb636cc26 adds
    this feature.
    
    Changes are done to use __builtin_set_fpscr_rn instead of mffscrn
    or mffscrni in __fe_mffscrn(rn).
    
    Suggested-by: Carl Love <cel@us.ibm.com>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Diff:
---
 sysdeps/powerpc/fpu/fenv_libc.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
index fa5e1c697e..a2a12d914b 100644
--- a/sysdeps/powerpc/fpu/fenv_libc.h
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
@@ -68,6 +68,14 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden;
     __fr;								\
   })
 
+/* Starting with GCC 14 __builtin_set_fpscr_rn can be used to return the
+   FPSCR fields as a double.  This support is available
+   on Power9 when the __SET_FPSCR_RN_RETURNS_FPSCR__ macro is defined.
+   To retain backward compatibility with older GCC, we still retain the
+   old inline assembly implementation.*/
+#ifdef __SET_FPSCR_RN_RETURNS_FPSCR__
+#define __fe_mffscrn(rn)  __builtin_set_fpscr_rn (rn)
+#else
 #define __fe_mffscrn(rn)						\
   ({register fenv_union_t __fr;						\
     if (__builtin_constant_p (rn))					\
@@ -83,6 +91,7 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden;
     }									\
     __fr.fenv;								\
   })
+#endif
 
 /* Like fegetenv_control, but also sets the rounding mode.  */
 #ifdef _ARCH_PWR9

                 reply	other threads:[~2023-09-27 16:57 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=20230927165735.27AA83857726@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@sourceware.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).