powerpc: Avoid putting floating point values in memory

Message ID 20170922181955.9392-1-tuliom@linux.vnet.ibm.com
State Committed
Delegated to: Joseph Myers
Headers

Commit Message

Tulio Magno Quites Machado Filho Sept. 22, 2017, 6:19 p.m. UTC
  2017-09-22  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>

	* sysdeps/powerpc/fpu/math_private.h (math_opt_barrier):
	(math_force_eval): Add powerpc version.
---
 sysdeps/powerpc/fpu/math_private.h | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Joseph Myers Sept. 22, 2017, 8:12 p.m. UTC | #1
Missing [BZ #22189] ChangeLog marker.
  
Adhemerval Zanella Sept. 22, 2017, 8:16 p.m. UTC | #2
On 22/09/2017 15:19, Tulio Magno Quites Machado Filho wrote:
> 2017-09-22  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
> 
> 	* sysdeps/powerpc/fpu/math_private.h (math_opt_barrier):
> 	(math_force_eval): Add powerpc version.
> ---
>  sysdeps/powerpc/fpu/math_private.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h
> index 396fd05..472182d 100644
> --- a/sysdeps/powerpc/fpu/math_private.h
> +++ b/sysdeps/powerpc/fpu/math_private.h
> @@ -23,6 +23,13 @@
>  #include <ldsodefs.h>
>  #include <dl-procinfo.h>
>  #include <fenv_private.h>
> +
> +/* Avoid putting floating point values in memory.  */
> +# define math_opt_barrier(x)					\
> +  ({ __typeof (x) __x = (x); __asm ("" : "+dwa" (__x)); __x; })
> +# define math_force_eval(x)						\
> +  ({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "dwa" (__x)); })
> +
>  #include_next <math_private.h>
>  
>  #if defined _ARCH_PWR9 && __HAVE_DISTINCT_FLOAT128
> 

LGTM, it seems to work on older GCC as well (4.8).
  
Tulio Magno Quites Machado Filho Sept. 22, 2017, 8:20 p.m. UTC | #3
Joseph Myers <joseph@codesourcery.com> writes:

> Missing [BZ #22189] ChangeLog marker.

I wasn't aware of that bug yet.

I'm adding it.

Thanks!
  

Patch

diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h
index 396fd05..472182d 100644
--- a/sysdeps/powerpc/fpu/math_private.h
+++ b/sysdeps/powerpc/fpu/math_private.h
@@ -23,6 +23,13 @@ 
 #include <ldsodefs.h>
 #include <dl-procinfo.h>
 #include <fenv_private.h>
+
+/* Avoid putting floating point values in memory.  */
+# define math_opt_barrier(x)					\
+  ({ __typeof (x) __x = (x); __asm ("" : "+dwa" (__x)); __x; })
+# define math_force_eval(x)						\
+  ({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "dwa" (__x)); })
+
 #include_next <math_private.h>
 
 #if defined _ARCH_PWR9 && __HAVE_DISTINCT_FLOAT128