public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] powerpc: Refactor fenvinline.h
@ 2020-02-25 23:15 Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; only message in thread
From: Tulio Magno Quites Machado Filho @ 2020-02-25 23:15 UTC (permalink / raw)
  To: glibc-cvs

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

commit f1a0840c15d039631c13258544cdc04e4cbb9c69
Author: Rogerio Alves <rcardoso@linux.ibm.com>
Date:   Mon Feb 10 12:09:02 2020 -0300

    powerpc: Refactor fenvinline.h
    
    This patch refactor fenviline.h replaces some statements for
    builtins.
    
    Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

Diff:
---
 sysdeps/powerpc/bits/fenvinline.h | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h
index 7068966..89ea38a 100644
--- a/sysdeps/powerpc/bits/fenvinline.h
+++ b/sysdeps/powerpc/bits/fenvinline.h
@@ -51,25 +51,34 @@
 # define fegetround() __fegetround ()
 
 # ifndef __NO_MATH_INLINES
+
+/* Builtins to mtfsb0 and mtfsb1 was introduced on GCC 9.  */
+#  if !__GNUC_PREREQ(9, 0)
 /* The weird 'i#*X' constraints on the following suppress a gcc
    warning when __excepts is not a constant.  Otherwise, they mean the
-   same as just plain 'i'.  */
+   same as just plain 'i'.  This warning only happens in old GCC
+   versions (gcc 3 or less).  Otherwise plain 'i' works fine.  */
+#   define __MTFSB0(__b) __asm__ __volatile__ ("mtfsb0 %0" : : "i#*X" (__b))
+#   define __MTFSB1(__b) __asm__ __volatile__ ("mtfsb1 %0" : : "i#*X" (__b))
+#  else
+#   define __MTFSB0(__b) __builtin_mtfsb0 (__b)
+#   define __MTFSB1(__b) __builtin_mtfsb1 (__b)
+#  endif
 
 #  if __GNUC_PREREQ(3, 4)
 
+#include <sys/param.h>
+
 /* Inline definition for feraiseexcept.  */
 #   define feraiseexcept(__excepts) \
   (__extension__  ({ 							      \
     int __e = __excepts;						      \
-    int __ret;								      \
+    int __ret = 0;							      \
     if (__builtin_constant_p (__e)					      \
-        && (__e & (__e - 1)) == 0					      \
+        && powerof2 (__e)						      \
         && __e != FE_INVALID)						      \
       {									      \
-	if (__e != 0)							      \
-	  __asm__ __volatile__ ("mtfsb1 %0"				      \
-				: : "i#*X" (__builtin_clz (__e)));	      \
-        __ret = 0;							      \
+	__MTFSB1 ((__builtin_clz (__e)));				      \
       }									      \
     else								      \
       __ret = feraiseexcept (__e);					      \
@@ -80,15 +89,12 @@
 #   define feclearexcept(__excepts) \
   (__extension__  ({ 							      \
     int __e = __excepts;						      \
-    int __ret;								      \
+    int __ret = 0;							      \
     if (__builtin_constant_p (__e)					      \
-        && (__e & (__e - 1)) == 0					      \
+        && powerof2 (__e)						      \
         && __e != FE_INVALID)						      \
       {									      \
-	if (__e != 0)							      \
-	  __asm__ __volatile__ ("mtfsb0 %0"				      \
-				: : "i#*X" (__builtin_clz (__e)));	      \
-        __ret = 0;							      \
+	__MTFSB0 ((__builtin_clz (__e)));				      \
       }									      \
     else								      \
       __ret = feclearexcept (__e);					      \


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-25 23:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 23:15 [glibc] powerpc: Refactor fenvinline.h Tulio Magno Quites Machado Filho

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).