public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: Fix f{max,min}{f} build for GCC 4.9 and 5
@ 2017-11-17 10:32 Adhemerval Zanella
  2017-11-17 10:40 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: Adhemerval Zanella @ 2017-11-17 10:32 UTC (permalink / raw)
  To: libc-alpha

GCC 4.9 and 5 do not generate a correct f{max,min}nm instruction for
__builtin_{fmax,fmin}{f} without -ffinite-math-only.  It is clear a
compiler issue since the instruction can handle NaN and Inf correctly
and GCC6+ does not show this issue.

We backport a fix to GCC 5, raise the minimum required GCC version
for aarch64 (since GCC 4.9 branch is now closed) and/or add configure
check to check for this issue.  However I think -ffinit-math-only
should be safe for these specific implementation and it is a much
simpler solution.

Checked on aarch64-linux-gnu with GCC 5.3.1.

	* sysdeps/aarch64/fpu/Makefile (CFLAGS-s_fmax.c, CFLAGS-s_fmaxf.c,
	CFLAGS-s_fmin.c, CFLAGS-s_fminf.c): New rule: add -ffinite-math-only.

[1] https://gcc.gnu.org/ml/gcc/2016-08/msg00010.html

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
 ChangeLog                    | 5 +++++
 sysdeps/aarch64/fpu/Makefile | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/sysdeps/aarch64/fpu/Makefile b/sysdeps/aarch64/fpu/Makefile
index bf38f2c..4a182bd 100644
--- a/sysdeps/aarch64/fpu/Makefile
+++ b/sysdeps/aarch64/fpu/Makefile
@@ -5,4 +5,10 @@ CFLAGS-s_lroundf.c += -fno-math-errno
 CFLAGS-s_lround.c += -fno-math-errno
 CFLAGS-s_llroundf.c += -fno-math-errno
 CFLAGS-s_llround.c += -fno-math-errno
+# GCC 4.9 and 5 requires the flag to correct emits a f{max,min}nm
+# for a __builtin_{fmax,fmin}{f}.
+CFLAGS-s_fmax.c += -ffinite-math-only
+CFLAGS-s_fmaxf.c += -ffinite-math-only
+CFLAGS-s_fmin.c += -ffinite-math-only
+CFLAGS-s_fminf.c += -ffinite-math-only
 endif
-- 
2.7.4

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

* Re: [PATCH] aarch64: Fix f{max,min}{f} build for GCC 4.9 and 5
  2017-11-17 10:32 [PATCH] aarch64: Fix f{max,min}{f} build for GCC 4.9 and 5 Adhemerval Zanella
@ 2017-11-17 10:40 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2017-11-17 10:40 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: nd

On 17/11/17 10:32, Adhemerval Zanella wrote:
> GCC 4.9 and 5 do not generate a correct f{max,min}nm instruction for
> __builtin_{fmax,fmin}{f} without -ffinite-math-only.  It is clear a
> compiler issue since the instruction can handle NaN and Inf correctly
> and GCC6+ does not show this issue.
> 
> We backport a fix to GCC 5, raise the minimum required GCC version
> for aarch64 (since GCC 4.9 branch is now closed) and/or add configure
> check to check for this issue.  However I think -ffinit-math-only
> should be safe for these specific implementation and it is a much
> simpler solution.
> 
> Checked on aarch64-linux-gnu with GCC 5.3.1.
> 
> 	* sysdeps/aarch64/fpu/Makefile (CFLAGS-s_fmax.c, CFLAGS-s_fmaxf.c,
> 	CFLAGS-s_fmin.c, CFLAGS-s_fminf.c): New rule: add -ffinite-math-only.
> 

OK.

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

end of thread, other threads:[~2017-11-17 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 10:32 [PATCH] aarch64: Fix f{max,min}{f} build for GCC 4.9 and 5 Adhemerval Zanella
2017-11-17 10:40 ` Szabolcs Nagy

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