]> sourceware.org Git - glibc.git/commitdiff
powerpc: Remove uses of operand modifier (%s) in inline asm
authorGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Fri, 22 Jan 2016 20:05:05 +0000 (18:05 -0200)
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Tue, 8 Mar 2016 18:30:28 +0000 (15:30 -0300)
The operand modifier %s on powerpc is an undocumented internal implementation
detail of GCC.  Besides that, the GCC community wants to remove it.  This patch
rewrites the expressions that use this modifier with logically equivalent
expressions that don't require it.

Explanation for the substitution:

The %s modifier takes an immediate operand and prints 32 less such immediate.
Thus, in the previous code, the expression resulted in:

  32 - __builtin_ffs(e)

where e was guaranteed to have exactly a single bit set, by the following
expressions:

  (e & (e-1) == 0) : e has at most one bit set.
  (e != 0)         : e is not zero, thus it has at least one bit set.

Since we guarantee that there is exactly only one bit set, the following
statement is true:

  32 - __builtin_ffs(e) == __builtin_clz(e)

Thus, we can replace __builtin_ffs with __builtin_clz and remove the %s operand
modifier.

ChangeLog
sysdeps/powerpc/bits/fenvinline.h

index 79a09044b7d7fcb4d03c72535df2113cd0da7d51..585c9c2d2e37d3378ef7875f4bdd711481445409 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-08  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/bits/fenvinline.h (feraiseexcept): Remove use of %s
+       operand modifier.
+       (feclearexcept): Likewise.
+
 2016-03-08  Carlos Eduardo Seo  <cseo@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Updated
index 4a7b2af6aa1c0f189c4c77f3fe198957dd09eb74..c283ede060587a68f54d16b907ff0448b59d6666 100644 (file)
    warning when __excepts is not a constant.  Otherwise, they mean the
    same as just plain 'i'.  */
 
+#  if __GNUC_PREREQ(3, 4)
+
 /* Inline definition for feraiseexcept.  */
-#  define feraiseexcept(__excepts) \
+#   define feraiseexcept(__excepts) \
   (__extension__  ({                                                         \
     int __e = __excepts;                                                     \
     int __ret;                                                               \
@@ -42,8 +44,8 @@
         && __e != FE_INVALID)                                                \
       {                                                                              \
        if (__e != 0)                                                         \
-         __asm__ __volatile__ ("mtfsb1 %s0"                                  \
-                               : : "i#*X" (__builtin_ffs (__e)));            \
+         __asm__ __volatile__ ("mtfsb1 %0"                                   \
+                               : : "i#*X" (__builtin_clz (__e)));            \
         __ret = 0;                                                           \
       }                                                                              \
     else                                                                     \
@@ -52,7 +54,7 @@
   }))
 
 /* Inline definition for feclearexcept.  */
-#  define feclearexcept(__excepts) \
+#   define feclearexcept(__excepts) \
   (__extension__  ({                                                         \
     int __e = __excepts;                                                     \
     int __ret;                                                               \
@@ -61,8 +63,8 @@
         && __e != FE_INVALID)                                                \
       {                                                                              \
        if (__e != 0)                                                         \
-         __asm__ __volatile__ ("mtfsb0 %s0"                                  \
-                               : : "i#*X" (__builtin_ffs (__e)));            \
+         __asm__ __volatile__ ("mtfsb0 %0"                                   \
+                               : : "i#*X" (__builtin_clz (__e)));            \
         __ret = 0;                                                           \
       }                                                                              \
     else                                                                     \
@@ -70,6 +72,8 @@
     __ret;                                                                   \
   }))
 
+#  endif /* __GNUC_PREREQ(3, 4).  */
+
 # endif /* !__NO_MATH_INLINES.  */
 
 #endif /* __GNUC__ && !_SOFT_FLOAT && !__NO_FPRS__ */
This page took 0.214366 seconds and 5 git commands to generate.