This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] PowerPC: Set/restore rounding mode only when needed
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 25 Nov 2013 18:17:16 -0200
- Subject: Re: [PATCH] PowerPC: Set/restore rounding mode only when needed
- Authentication-results: sourceware.org; auth=none
- References: <5280DDA5 dot 1060906 at linux dot vnet dot ibm dot com> <20131119131935 dot GE24544 at spoyarek dot pnq dot redhat dot com> <528CBBE7 dot 8040109 at linux dot vnet dot ibm dot com> <20131125095330 dot GN19834 at spoyarek dot pnq dot redhat dot com> <5293450A dot 20607 at linux dot vnet dot ibm dot com>
On 25-11-2013 10:39, Adhemerval Zanella wrote:
> Hi Siddhesh, thanks again for the review.
>
>
> On 25-11-2013 07:53, Siddhesh Poyarekar wrote:
>>> +static __always_inline void
>>>> +libc_fesetround_ppc (int r)
>>>> +{
>>>> + fesetround (r);
>> Shouldn't this be __fesetround? The rest of the patch looks OK to me.
>>
>> Siddhesh
>>
> Indeed this is a missing optimization, I have fixed it.
>
> Pushed upstream as 41e8926aa4b7f17bc95984737ee82a254ad0911c.
>
This is follow up fix noted by missing symbol Andreas Schwab due a incomplete patch
(I apologize for this). The issue is due the hidden_attribute on __fe_nomask_env which
make the variable not being exported in the right way.
The patch is simple: rename the function to an internal way (I use the 'priv' suffix
because double underscore is already there), remove the attribute_hidden and use
the new implementation on old code. The new symbol name is required to avoid PLT
creation inside libm. Tested for PPC32 and PPC64 (yes, I didn't screw my testing this
time).
---
2013-11-25 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/fpu/feenablxcpt.c (feenableexcept): Use
__fe_nomask_env_priv instead of __fe_nomask_env to avoid a PLT call.
* sysdeps/powerpc/fpu/fesetenv.c (__fesetenv): Likewise.
* sysdeps/powerpc/fpu/feupdateenv.c (__feupdateenv): Likewise.
* sysdeps/powerpc/fpu/fenv_libc.h (__fe_nomask_env): Rename to
__fe_nomask_env_priv and attribute_hidden.
* sysdeps/powerpc/fpu/fenv_private.h (libc_fesetenv_ppc): Likewise.
(libc_feupdateenv_test_ppc): Likewise.
(libc_feresetround_ppc): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
(__fe_nomask_env): Rename to __fe_nomask_env_priv and adjust
compat_symbol macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
(__fe_nomask_env): Likewise.
--
diff --git a/sysdeps/powerpc/fpu/feenablxcpt.c b/sysdeps/powerpc/fpu/feenablxcpt.c
index 472796d..35e977e 100644
--- a/sysdeps/powerpc/fpu/feenablxcpt.c
+++ b/sysdeps/powerpc/fpu/feenablxcpt.c
@@ -45,7 +45,7 @@ feenableexcept (int excepts)
new = __fegetexcept ();
if (new != 0 && result == 0)
- (void)__fe_nomask_env ();
+ (void) __fe_nomask_env_priv ();
if ((new & excepts) != excepts)
result = -1;
diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
index ecd6b91..74d633d 100644
--- a/sysdeps/powerpc/fpu/fenv_libc.h
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
@@ -23,7 +23,7 @@
#include <ldsodefs.h>
#include <sysdep.h>
-extern const fenv_t *__fe_nomask_env (void) attribute_hidden;
+extern const fenv_t *__fe_nomask_env_priv (void);
extern const fenv_t *__fe_mask_env (void) attribute_hidden;
diff --git a/sysdeps/powerpc/fpu/fenv_private.h b/sysdeps/powerpc/fpu/fenv_private.h
index 293f840..bc78c3f 100644
--- a/sysdeps/powerpc/fpu/fenv_private.h
+++ b/sysdeps/powerpc/fpu/fenv_private.h
@@ -96,7 +96,7 @@ libc_fesetenv_ppc (const fenv_t *envp)
hardware into "precise mode" and may cause the FPU to run slower on some
hardware. */
if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
- (void) __fe_nomask_env ();
+ (void) __fe_nomask_env_priv ();
/* If the old env had any enabled exceptions and the new env has no enabled
exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
@@ -123,7 +123,7 @@ libc_feupdateenv_test_ppc (fenv_t *envp, int ex)
| (new.l & _FPU_MASK_FRAC_INEX_RET_CC);
if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
- (void) __fe_nomask_env ();
+ (void) __fe_nomask_env_priv ();
if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
(void) __fe_mask_env ();
@@ -169,7 +169,7 @@ libc_feresetround_ppc (fenv_t *envp)
| (new.l & _FPU_MASK_FRAC_INEX_RET_CC);
if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
- (void) __fe_nomask_env ();
+ (void) __fe_nomask_env_priv ();
if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
(void) __fe_mask_env ();
diff --git a/sysdeps/powerpc/fpu/fesetenv.c b/sysdeps/powerpc/fpu/fesetenv.c
index 6c00b26..5de6ff5 100644
--- a/sysdeps/powerpc/fpu/fesetenv.c
+++ b/sysdeps/powerpc/fpu/fesetenv.c
@@ -35,7 +35,7 @@ __fesetenv (const fenv_t *envp)
hardware into "precise mode" and may cause the FPU to run slower on some
hardware. */
if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
- (void)__fe_nomask_env ();
+ (void) __fe_nomask_env_priv ();
/* If the old env had any enabled exceptions and the new env has no enabled
exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
diff --git a/sysdeps/powerpc/fpu/feupdateenv.c b/sysdeps/powerpc/fpu/feupdateenv.c
index 6775044..262e213 100644
--- a/sysdeps/powerpc/fpu/feupdateenv.c
+++ b/sysdeps/powerpc/fpu/feupdateenv.c
@@ -41,7 +41,7 @@ __feupdateenv (const fenv_t *envp)
the hardware into "precise mode" and may cause the FPU to run slower on
some hardware. */
if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
- (void)__fe_nomask_env ();
+ (void) __fe_nomask_env_priv ();
/* If the old env had any enabled exceptions and the new env has no enabled
exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
index 5a94dc5..49b73d2 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
@@ -26,7 +26,7 @@
#include <shlib-compat.h>
const fenv_t *
-__fe_nomask_env (void)
+__fe_nomask_env_priv (void)
{
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL (prctl, err, 2, PR_SET_FPEXC, PR_FP_EXC_PRECISE);
@@ -34,5 +34,5 @@ __fe_nomask_env (void)
return FE_ENABLED_ENV;
}
#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_19)
-compat_symbol (libm, __fe_nomask_env, __fe_nomask_env, GLIBC_2_1);
+compat_symbol (libm, __fe_nomask_env_priv, __fe_nomask_env, GLIBC_2_1);
#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
index 70661ad..8532518 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
@@ -25,7 +25,7 @@
#include <shlib-compat.h>
const fenv_t *
-__fe_nomask_env (void)
+__fe_nomask_env_priv (void)
{
#if defined PR_SET_FPEXC && defined PR_FP_EXC_PRECISE
INTERNAL_SYSCALL_DECL (err);
@@ -36,5 +36,5 @@ __fe_nomask_env (void)
return FE_ENABLED_ENV;
}
#if SHLIB_COMPAT (libm, GLIBC_2_3, GLIBC_2_19)
-compat_symbol (libm, __fe_nomask_env, __fe_nomask_env, GLIBC_2_3);
+compat_symbol (libm, __fe_nomask_env_priv, __fe_nomask_env, GLIBC_2_3);
#endif