* [powerpc] fenvinline.h uses assembly modifier 's'
@ 2016-01-15 22:57 Tim Shen
2016-01-21 12:41 ` Tulio Magno Quites Machado Filho
0 siblings, 1 reply; 9+ messages in thread
From: Tim Shen @ 2016-01-15 22:57 UTC (permalink / raw)
To: libc-alpha
...at here: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/bits/fenvinline.h;hb=a3e5b4feeb54cb92657ec2bc6d9be1fcef9e8575#l45
The 's' modifier support is still in gcc 5 branch's
rs6000.c:print_operand, but not supported in the trunk. It's removed
by gcc patch r226005.
Is glibc the right place to fix this by not using %s0?
Thanks!
--
Regards,
Tim Shen
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [powerpc] fenvinline.h uses assembly modifier 's'
2016-01-15 22:57 [powerpc] fenvinline.h uses assembly modifier 's' Tim Shen
@ 2016-01-21 12:41 ` Tulio Magno Quites Machado Filho
2016-01-27 13:25 ` [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm Gabriel F. T. Gomes
0 siblings, 1 reply; 9+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2016-01-21 12:41 UTC (permalink / raw)
To: Tim Shen; +Cc: libc-alpha
Tim Shen <timshen@google.com> writes:
> The 's' modifier support is still in gcc 5 branch's
> rs6000.c:print_operand, but not supported in the trunk. It's removed
> by gcc patch r226005.
>
> Is glibc the right place to fix this by not using %s0?
Yes.
Thanks for the note,
--
Tulio Magno
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
2016-01-21 12:41 ` Tulio Magno Quites Machado Filho
@ 2016-01-27 13:25 ` Gabriel F. T. Gomes
2016-01-27 13:30 ` Gabriel F. T. Gomes
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Gabriel F. T. Gomes @ 2016-01-27 13:25 UTC (permalink / raw)
To: tuliom; +Cc: timshen, libc-alpha
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.
2016-01-25 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
* sysdeps/powerpc/bits/fenvinline.h (feraiseexcept): Remove use of %s
operand modifier.
(feclearexcept): Likewise.
---
sysdeps/powerpc/bits/fenvinline.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h
index 4a7b2af..7d7938e 100644
--- a/sysdeps/powerpc/bits/fenvinline.h
+++ b/sysdeps/powerpc/bits/fenvinline.h
@@ -42,8 +42,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 \
@@ -61,8 +61,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 \
--
2.4.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
2016-01-27 13:25 ` [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm Gabriel F. T. Gomes
@ 2016-01-27 13:30 ` Gabriel F. T. Gomes
2016-01-27 13:51 ` Adhemerval Zanella
2016-01-27 17:19 ` Joseph Myers
2 siblings, 0 replies; 9+ messages in thread
From: Gabriel F. T. Gomes @ 2016-01-27 13:30 UTC (permalink / raw)
To: tuliom; +Cc: timshen, libc-alpha
Oops.
I forgot to mention that this is for 2.24 and that I tested it on ppc,
ppc64, and ppc64le.
Sorry about that.
Kind regards,
Gabriel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
2016-01-27 13:25 ` [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm Gabriel F. T. Gomes
2016-01-27 13:30 ` Gabriel F. T. Gomes
@ 2016-01-27 13:51 ` Adhemerval Zanella
2016-01-27 17:19 ` Joseph Myers
2 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2016-01-27 13:51 UTC (permalink / raw)
To: libc-alpha
GCC developers seems to have included this modifier back [1], should we really
need it (is there a released version that do not support it)?
[1] https://gcc.gnu.org/ml/gcc-patches/2016-01/msg01937.html
On 27-01-2016 11:25, Gabriel F. T. Gomes wrote:
> 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.
>
> 2016-01-25 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
>
> * sysdeps/powerpc/bits/fenvinline.h (feraiseexcept): Remove use of %s
> operand modifier.
> (feclearexcept): Likewise.
> ---
> sysdeps/powerpc/bits/fenvinline.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h
> index 4a7b2af..7d7938e 100644
> --- a/sysdeps/powerpc/bits/fenvinline.h
> +++ b/sysdeps/powerpc/bits/fenvinline.h
> @@ -42,8 +42,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 \
> @@ -61,8 +61,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 \
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
2016-01-27 13:25 ` [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm Gabriel F. T. Gomes
2016-01-27 13:30 ` Gabriel F. T. Gomes
2016-01-27 13:51 ` Adhemerval Zanella
@ 2016-01-27 17:19 ` Joseph Myers
2016-01-29 18:14 ` Gabriel F. T. Gomes
2 siblings, 1 reply; 9+ messages in thread
From: Joseph Myers @ 2016-01-27 17:19 UTC (permalink / raw)
To: Gabriel F. T. Gomes; +Cc: tuliom, timshen, libc-alpha
On Wed, 27 Jan 2016, Gabriel F. T. Gomes wrote:
> Thus, we can replace __builtin_ffs with __builtin_clz and remove the %s operand
> modifier.
Doesn't that mean you need to make these definitions conditional on
__GNUC_PREREQ (3, 4) (which I think should be fine to do - we shouldn't
need to care about these optimizations for pre-3.4 compilers), as that was
the version where __builtin_clz was introduced?
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
2016-01-27 17:19 ` Joseph Myers
@ 2016-01-29 18:14 ` Gabriel F. T. Gomes
2016-03-08 18:36 ` Tulio Magno Quites Machado Filho
0 siblings, 1 reply; 9+ messages in thread
From: Gabriel F. T. Gomes @ 2016-01-29 18:14 UTC (permalink / raw)
To: Joseph Myers; +Cc: tuliom, timshen, libc-alpha
[-- Attachment #1: Type: text/plain, Size: 571 bytes --]
On Wed, 27 Jan 2016 17:19:12 +0000
Joseph Myers <joseph@codesourcery.com> wrote:
> On Wed, 27 Jan 2016, Gabriel F. T. Gomes wrote:
>
> > Thus, we can replace __builtin_ffs with __builtin_clz and remove
> > the %s operand modifier.
>
> Doesn't that mean you need to make these definitions conditional on
> __GNUC_PREREQ (3, 4) (which I think should be fine to do - we
> shouldn't need to care about these optimizations for pre-3.4
> compilers), as that was the version where __builtin_clz was
> introduced?
>
I agree.
The attached patch addresses your concerns.
[-- Attachment #2: 0001-powerpc-Remove-uses-of-operand-modifier-s-in-inline-.patch --]
[-- Type: text/x-patch, Size: 3252 bytes --]
From 978a2e3f70d60f68171c97b7c5e0cdcf0436d6b5 Mon Sep 17 00:00:00 2001
From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
Date: Fri, 22 Jan 2016 18:05:05 -0200
Subject: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
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.
2016-01-25 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
* sysdeps/powerpc/bits/fenvinline.h (feraiseexcept): Remove use of %s
operand modifier.
(feclearexcept): Likewise.
---
sysdeps/powerpc/bits/fenvinline.h | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h
index 4a7b2af..c283ede 100644
--- a/sysdeps/powerpc/bits/fenvinline.h
+++ b/sysdeps/powerpc/bits/fenvinline.h
@@ -32,8 +32,10 @@
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__ */
--
2.4.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
2016-01-29 18:14 ` Gabriel F. T. Gomes
@ 2016-03-08 18:36 ` Tulio Magno Quites Machado Filho
0 siblings, 0 replies; 9+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2016-03-08 18:36 UTC (permalink / raw)
To: Gabriel F. T. Gomes; +Cc: Joseph Myers, timshen, libc-alpha
"Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com> writes:
> Subject: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
>
> 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.
Pushed as 183a34d.
Thanks!
--
Tulio Magno
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
@ 2016-01-27 14:30 David Edelsohn
0 siblings, 0 replies; 9+ messages in thread
From: David Edelsohn @ 2016-01-27 14:30 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library
>>>>> Adhemerval Zanella wrote:
> GCC developers seems to have included this modifier back [1], should we really
> need it (is there a released version that do not support it)?
GCC restored the modifier because libc uses it in a public header and
GCC needs to provide backward compatibility while the modifier is
deprecated. There was no GCC release that lacked support for the
modifier.
Please remove the use of the modifier in GLIBC. Please don't search
for reasons to preserve it.
Thanks, David
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-03-08 18:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15 22:57 [powerpc] fenvinline.h uses assembly modifier 's' Tim Shen
2016-01-21 12:41 ` Tulio Magno Quites Machado Filho
2016-01-27 13:25 ` [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm Gabriel F. T. Gomes
2016-01-27 13:30 ` Gabriel F. T. Gomes
2016-01-27 13:51 ` Adhemerval Zanella
2016-01-27 17:19 ` Joseph Myers
2016-01-29 18:14 ` Gabriel F. T. Gomes
2016-03-08 18:36 ` Tulio Magno Quites Machado Filho
2016-01-27 14:30 David Edelsohn
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).