public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][AArch64] Use builtins for fpcr/fpsr
@ 2018-01-09 11:38 Wilco Dijkstra
  2018-01-18 13:57 ` Szabolcs Nagy
  0 siblings, 1 reply; 8+ messages in thread
From: Wilco Dijkstra @ 2018-01-09 11:38 UTC (permalink / raw)
  To: libc-alpha; +Cc: nd

Since GCC 5 has builtin support for accessing FPSR/FPCR, use them when possible
so that the asm instructions can be removed eventually.

GLIBC build and test OK.

ChangeLog:
2018-01-09  Wilco Dijkstra  <wdijkstr@arm.com>

	* sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing FPCR/FPSR.
--
diff --git a/sysdeps/aarch64/fpu/fpu_control.h b/sysdeps/aarch64/fpu/fpu_control.h
index 570e3dca78adbbccdc21ca879c582e1e09196f2d..d7ed28e3c1d7bd4a89087604f80268c36c890c80 100644
--- a/sysdeps/aarch64/fpu/fpu_control.h
+++ b/sysdeps/aarch64/fpu/fpu_control.h
@@ -21,17 +21,24 @@
 
 /* Macros for accessing the FPCR and FPSR.  */
 
-#define _FPU_GETCW(fpcr) \
+#if __GNUC_PREREQ (5,0)
+# define _FPU_GETCW(fpcr) (fpcr = __builtin_aarch64_get_fpcr ())
+# define _FPU_SETCW(fpcr) __builtin_aarch64_set_fpcr (fpcr)
+# define _FPU_GETFPSR(fpsr) (fpsr = __builtin_aarch64_get_fpsr ())
+# define _FPU_SETFPSR(fpsr) __builtin_aarch64_set_fpsr (fpsr)
+#else
+# define _FPU_GETCW(fpcr) \
   __asm__ __volatile__ ("mrs	%0, fpcr" : "=r" (fpcr))
 
-#define _FPU_SETCW(fpcr) \
+# define _FPU_SETCW(fpcr) \
   __asm__ __volatile__ ("msr	fpcr, %0" : : "r" (fpcr))
 
-#define _FPU_GETFPSR(fpsr) \
+# define _FPU_GETFPSR(fpsr) \
   __asm__ __volatile__ ("mrs	%0, fpsr" : "=r" (fpsr))
 
-#define _FPU_SETFPSR(fpsr) \
+# define _FPU_SETFPSR(fpsr) \
   __asm__ __volatile__ ("msr	fpsr, %0" : : "r" (fpsr))
+#endif
 
 /* Reserved bits should be preserved when modifying register
    contents. These two masks indicate which bits in each of FPCR and

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-01-09 11:38 [PATCH][AArch64] Use builtins for fpcr/fpsr Wilco Dijkstra
@ 2018-01-18 13:57 ` Szabolcs Nagy
  2018-01-19 13:18   ` Wilco Dijkstra
  0 siblings, 1 reply; 8+ messages in thread
From: Szabolcs Nagy @ 2018-01-18 13:57 UTC (permalink / raw)
  To: Wilco Dijkstra, libc-alpha; +Cc: nd

On 09/01/18 11:38, Wilco Dijkstra wrote:
> Since GCC 5 has builtin support for accessing FPSR/FPCR, use them when possible
> so that the asm instructions can be removed eventually.
> 
> GLIBC build and test OK.
> 

this will have to wait for the next release, but please
increase the gcc prereq to 6.0 because i see ice on gcc-5:

aarch64-none-linux-gnu-gcc ../sysdeps/aarch64/fpu/fesetenv.c -c [..]
../sysdeps/aarch64/fpu/fesetenv.c: In function '__fesetenv':
../sysdeps/aarch64/fpu/fesetenv.c:75:1: error: unrecognizable insn:
 }
 ^
(insn 23 22 4 6 (unspec_volatile [
            (mem:SI (plus:DI (reg/v/f:DI 85 [ envp ])
                    (const_int 4 [0x4])) [2 envp_8(D)->__fpsr+0 S4 A32])
        ] UNSPECV_SET_FPSR) ../sysdeps/aarch64/fpu/fesetenv.c:41 -1
     (nil))
../sysdeps/aarch64/fpu/fesetenv.c:75:1: internal compiler error: in extract_insn, at recog.c:2343

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-01-18 13:57 ` Szabolcs Nagy
@ 2018-01-19 13:18   ` Wilco Dijkstra
  2018-02-09 15:06     ` Wilco Dijkstra
  0 siblings, 1 reply; 8+ messages in thread
From: Wilco Dijkstra @ 2018-01-19 13:18 UTC (permalink / raw)
  To: Szabolcs Nagy, libc-alpha; +Cc: nd

Szabolcs Nagy wrote:

> this will have to wait for the next release, but please
> increase the gcc prereq to 6.0 because i see ice on gcc-5:

aarch64-none-linux-gnu-gcc ../sysdeps/aarch64/fpu/fesetenv.c -c [..]
../sysdeps/aarch64/fpu/fesetenv.c: In function '__fesetenv':
../sysdeps/aarch64/fpu/fesetenv.c:75:1: error: unrecognizable insn:
 }
 ^
(insn 23 22 4 6 (unspec_volatile [
            (mem:SI (plus:DI (reg/v/f:DI 85 [ envp ])
                    (const_int 4 [0x4])) [2 envp_8(D)->__fpsr+0 S4 A32])
        ] UNSPECV_SET_FPSR) ../sysdeps/aarch64/fpu/fesetenv.c:41 -1
     (nil))
../sysdeps/aarch64/fpu/fesetenv.c:75:1: internal compiler error: in extract_insn, at recog.c:2343

Looks like it's merging a MEM into a register operand. Since GCC5 is no longer
supported I've updated it to GCC6:

Since GCC has support for accessing FPSR/FPCR, use them when possible
so that the asm instructions can be removed eventually.  Although GCC 5
supports the builtins, it has an optimization bug, so use them from GCC 6
onwards.

GLIBC build and test OK.

ChangeLog:
2018-01-19  Wilco Dijkstra  <wdijkstr@arm.com>

	* sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing FPCR/FPSR.

diff --git a/sysdeps/aarch64/fpu/fpu_control.h b/sysdeps/aarch64/fpu/fpu_control.h
index 570e3dca78adbbccdc21ca879c582e1e09196f2d..d0cc5afc9faf42249a45b7f6b24a374f944998fd 100644
--- a/sysdeps/aarch64/fpu/fpu_control.h
+++ b/sysdeps/aarch64/fpu/fpu_control.h
@@ -21,17 +21,24 @@
 
 /* Macros for accessing the FPCR and FPSR.  */
 
-#define _FPU_GETCW(fpcr) \
+#if __GNUC_PREREQ (6,0)
+# define _FPU_GETCW(fpcr) (fpcr = __builtin_aarch64_get_fpcr ())
+# define _FPU_SETCW(fpcr) __builtin_aarch64_set_fpcr (fpcr)
+# define _FPU_GETFPSR(fpsr) (fpsr = __builtin_aarch64_get_fpsr ())
+# define _FPU_SETFPSR(fpsr) __builtin_aarch64_set_fpsr (fpsr)
+#else
+# define _FPU_GETCW(fpcr) \
   __asm__ __volatile__ ("mrs	%0, fpcr" : "=r" (fpcr))
 
-#define _FPU_SETCW(fpcr) \
+# define _FPU_SETCW(fpcr) \
   __asm__ __volatile__ ("msr	fpcr, %0" : : "r" (fpcr))
 
-#define _FPU_GETFPSR(fpsr) \
+# define _FPU_GETFPSR(fpsr) \
   __asm__ __volatile__ ("mrs	%0, fpsr" : "=r" (fpsr))
 
-#define _FPU_SETFPSR(fpsr) \
+# define _FPU_SETFPSR(fpsr) \
   __asm__ __volatile__ ("msr	fpsr, %0" : : "r" (fpsr))
+#endif
 
 /* Reserved bits should be preserved when modifying register
    contents. These two masks indicate which bits in each of FPCR and

    

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-01-19 13:18   ` Wilco Dijkstra
@ 2018-02-09 15:06     ` Wilco Dijkstra
  2018-02-09 17:34       ` Szabolcs Nagy
  2018-02-09 23:23       ` Joseph Myers
  0 siblings, 2 replies; 8+ messages in thread
From: Wilco Dijkstra @ 2018-02-09 15:06 UTC (permalink / raw)
  To: Szabolcs Nagy, libc-alpha; +Cc: nd


ping


From: Wilco Dijkstra
Sent: 19 January 2018 13:18
To: Szabolcs Nagy; libc-alpha@sourceware.org
Cc: nd
Subject: Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  

Szabolcs Nagy wrote:

> this will have to wait for the next release, but please
> increase the gcc prereq to 6.0 because i see ice on gcc-5:

aarch64-none-linux-gnu-gcc ../sysdeps/aarch64/fpu/fesetenv.c -c [..]
../sysdeps/aarch64/fpu/fesetenv.c: In function '__fesetenv':
../sysdeps/aarch64/fpu/fesetenv.c:75:1: error: unrecognizable insn:
 }
 ^
(insn 23 22 4 6 (unspec_volatile [
            (mem:SI (plus:DI (reg/v/f:DI 85 [ envp ])
                    (const_int 4 [0x4])) [2 envp_8(D)->__fpsr+0 S4 A32])
        ] UNSPECV_SET_FPSR) ../sysdeps/aarch64/fpu/fesetenv.c:41 -1
     (nil))
../sysdeps/aarch64/fpu/fesetenv.c:75:1: internal compiler error: in extract_insn, at recog.c:2343

Looks like it's merging a MEM into a register operand. Since GCC5 is no longer
supported I've updated it to GCC6:

Since GCC has support for accessing FPSR/FPCR, use them when possible
so that the asm instructions can be removed eventually.  Although GCC 5
supports the builtins, it has an optimization bug, so use them from GCC 6
onwards.

GLIBC build and test OK.

ChangeLog:
2018-01-19  Wilco Dijkstra  <wdijkstr@arm.com>

        * sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing FPCR/FPSR.

diff --git a/sysdeps/aarch64/fpu/fpu_control.h b/sysdeps/aarch64/fpu/fpu_control.h
index 570e3dca78adbbccdc21ca879c582e1e09196f2d..d0cc5afc9faf42249a45b7f6b24a374f944998fd 100644
--- a/sysdeps/aarch64/fpu/fpu_control.h
+++ b/sysdeps/aarch64/fpu/fpu_control.h
@@ -21,17 +21,24 @@
 
 /* Macros for accessing the FPCR and FPSR.  */
 
-#define _FPU_GETCW(fpcr) \
+#if __GNUC_PREREQ (6,0)
+# define _FPU_GETCW(fpcr) (fpcr = __builtin_aarch64_get_fpcr ())
+# define _FPU_SETCW(fpcr) __builtin_aarch64_set_fpcr (fpcr)
+# define _FPU_GETFPSR(fpsr) (fpsr = __builtin_aarch64_get_fpsr ())
+# define _FPU_SETFPSR(fpsr) __builtin_aarch64_set_fpsr (fpsr)
+#else
+# define _FPU_GETCW(fpcr) \
   __asm__ __volatile__ ("mrs   %0, fpcr" : "=r" (fpcr))
 
-#define _FPU_SETCW(fpcr) \
+# define _FPU_SETCW(fpcr) \
   __asm__ __volatile__ ("msr   fpcr, %0" : : "r" (fpcr))
 
-#define _FPU_GETFPSR(fpsr) \
+# define _FPU_GETFPSR(fpsr) \
   __asm__ __volatile__ ("mrs   %0, fpsr" : "=r" (fpsr))
 
-#define _FPU_SETFPSR(fpsr) \
+# define _FPU_SETFPSR(fpsr) \
   __asm__ __volatile__ ("msr   fpsr, %0" : : "r" (fpsr))
+#endif
 
 /* Reserved bits should be preserved when modifying register
    contents. These two masks indicate which bits in each of FPCR and

        

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-02-09 15:06     ` Wilco Dijkstra
@ 2018-02-09 17:34       ` Szabolcs Nagy
  2018-02-09 23:23       ` Joseph Myers
  1 sibling, 0 replies; 8+ messages in thread
From: Szabolcs Nagy @ 2018-02-09 17:34 UTC (permalink / raw)
  To: Wilco Dijkstra, libc-alpha; +Cc: nd

On 09/02/18 15:03, Wilco Dijkstra wrote:
> Since GCC has support for accessing FPSR/FPCR, use them when possible
> so that the asm instructions can be removed eventually.  Although GCC 5
> supports the builtins, it has an optimization bug, so use them from GCC 6
> onwards.
> 
> GLIBC build and test OK.
> 
> ChangeLog:
> 2018-01-19  Wilco Dijkstra  <wdijkstr@arm.com>
> 
>          * sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing FPCR/FPSR.
> 

ok to commit.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-02-09 15:06     ` Wilco Dijkstra
  2018-02-09 17:34       ` Szabolcs Nagy
@ 2018-02-09 23:23       ` Joseph Myers
  2018-02-10 18:16         ` Wilco Dijkstra
  1 sibling, 1 reply; 8+ messages in thread
From: Joseph Myers @ 2018-02-09 23:23 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: Szabolcs Nagy, libc-alpha, nd

I'm seeing:

In file included from ../include/fpu_control.h:2:0,
                 from test-fpucw.c:19:
../sysdeps/aarch64/fpu/fpu_control.h:24:5: error: "__GNUC_PREREQ" is not defined, evaluates to 0 [-Werror=undef]
 #if __GNUC_PREREQ (6,0)
     ^~~~~~~~~~~~~
../sysdeps/aarch64/fpu/fpu_control.h:24:19: error: missing binary operator before token "("
 #if __GNUC_PREREQ (6,0)
                   ^

fpu_control.h is missing an include of features.h, as needed to use 
__GNUC_PREREQ.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-02-09 23:23       ` Joseph Myers
@ 2018-02-10 18:16         ` Wilco Dijkstra
  2018-02-12 14:13           ` Joseph Myers
  0 siblings, 1 reply; 8+ messages in thread
From: Wilco Dijkstra @ 2018-02-10 18:16 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Szabolcs Nagy, libc-alpha, nd

Joseph Myers wrote:
  
In file included from ../include/fpu_control.h:2:0,
                 from test-fpucw.c:19:
../sysdeps/aarch64/fpu/fpu_control.h:24:5: error: "__GNUC_PREREQ" is not defined, evaluates to 0 [-Werror=undef]

> fpu_control.h is missing an include of features.h, as needed to use 
> __GNUC_PREREQ.

Yes, I added the include but forgot to merge it with the patch. Now committed.

Wilco
    

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH][AArch64] Use builtins for fpcr/fpsr
  2018-02-10 18:16         ` Wilco Dijkstra
@ 2018-02-12 14:13           ` Joseph Myers
  0 siblings, 0 replies; 8+ messages in thread
From: Joseph Myers @ 2018-02-12 14:13 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: Szabolcs Nagy, libc-alpha, nd

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On Sat, 10 Feb 2018, Wilco Dijkstra wrote:

> Joseph Myers wrote:
>   
> In file included from ../include/fpu_control.h:2:0,
>                  from test-fpucw.c:19:
> ../sysdeps/aarch64/fpu/fpu_control.h:24:5: error: "__GNUC_PREREQ" is not defined, evaluates to 0 [-Werror=undef]
> 
> > fpu_control.h is missing an include of features.h, as needed to use 
> > __GNUC_PREREQ.
> 
> Yes, I added the include but forgot to merge it with the patch. Now committed.

Normal practice in glibc installed headers (and more generally in glibc) 
is to use #include <>, not #include "" as in that change.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-02-12 14:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 11:38 [PATCH][AArch64] Use builtins for fpcr/fpsr Wilco Dijkstra
2018-01-18 13:57 ` Szabolcs Nagy
2018-01-19 13:18   ` Wilco Dijkstra
2018-02-09 15:06     ` Wilco Dijkstra
2018-02-09 17:34       ` Szabolcs Nagy
2018-02-09 23:23       ` Joseph Myers
2018-02-10 18:16         ` Wilco Dijkstra
2018-02-12 14:13           ` Joseph Myers

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