Patchwork aarch64: Implement math acceleration via builtins

login
register
mail settings
Submitter Szabolcs Nagy
Date Oct. 23, 2017, 2:43 p.m.
Message ID <59EE0019.5080000@arm.com>
Download mbox | patch
Permalink /patch/23770/
State New
Headers show

Comments

Szabolcs Nagy - Oct. 23, 2017, 2:43 p.m.
On 20/10/17 21:16, Michael Collison wrote:
> Patch updated with upstream comments. ChangeLog updated as well.
> 
> Tested on aarch64-linux-gnu with gcc-5.4 and gcc-6. Okay for trunk?
> 
> 2017-10-20  Michael Collison  <michael.collison@arm.com>
...
>> 	* sysdeps/aarch64/fpu/Makefile: Build e_sqrt[f].c with
>> 	-fno-math-errno.

i managed to miss this new Makefile in the commit.

but then i saw that lround, llround, lroundf, llroundf builtins
fail to inline as single instruction without -fno-math-errno
(at least with the toolchain i tried), so i added those to
the makefile, committed as in the attached patch.

however this feels fragile, we probably have to add the
-fno-math-errno flag to all math functions.

Patch

From be080b6c143901d998c91f28ef7b2fe4a25c0237 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Mon, 23 Oct 2017 15:31:37 +0100
Subject: [PATCH] aarch64: Add missing math Makefile for recent commit

Without -fno-math-errno, the builtins just do a call instead of
inlining a single instruction.
---
 ChangeLog                    | 3 ++-
 sysdeps/aarch64/fpu/Makefile | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/aarch64/fpu/Makefile

diff --git a/ChangeLog b/ChangeLog
index 4a011b136b..1316b401ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,7 +55,8 @@ 
 	with __builtin_trunc.
 	* sysdeps/aarch64/fpu/s_truncf.c (__truncf): Replace asm statements
 	with __builtin_truncf.
-	* sysdeps/aarch64/fpu/Makefile: Build e_sqrt[f].c with -fno-math-errno.
+	* sysdeps/aarch64/fpu/Makefile: Build e_sqrt[f].c with -fno-math-errno,
+	and s_l[l]round[f].c too.
 
 2017-10-23  Alan Modra  <amodra@gmail.com>
 
diff --git a/sysdeps/aarch64/fpu/Makefile b/sysdeps/aarch64/fpu/Makefile
new file mode 100644
index 0000000000..bf38f2c589
--- /dev/null
+++ b/sysdeps/aarch64/fpu/Makefile
@@ -0,0 +1,8 @@ 
+ifeq ($(subdir),math)
+CFLAGS-e_sqrtf.c += -fno-math-errno
+CFLAGS-e_sqrt.c += -fno-math-errno
+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
+endif
-- 
2.11.0