aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorThomas Preud'homme <thopre01@gcc.gnu.org>2018-12-19 17:34:18 +0000
committerThomas Preud'homme <thopre01@gcc.gnu.org>2018-12-19 17:34:18 +0000
commit72e3a529238a86235f74f563d13f27b26b2b816b (patch)
tree2470dfe1119acfbbf4d3ce2d93a9fded5cb0f681 /libgcc
parentc4686fa91e3f4852f0182df220ced85b6ff0e13c (diff)
downloadgcc-72e3a529238a86235f74f563d13f27b26b2b816b.zip
gcc-72e3a529238a86235f74f563d13f27b26b2b816b.tar.gz
gcc-72e3a529238a86235f74f563d13f27b26b2b816b.tar.bz2
[ARM] Optimize executable size when using softfloat fmul/dmul
Softfloat single precision and double precision floating-point multiplication routines in libgcc share some code with the floating-point division of their corresponding precision. As the code is structured now, this leads to *all* division code being pulled in an executable in softfloat mode even if only multiplication is performed. This patch create some new LIB1ASMFUNCS macros to also build files with just the multiplication and shared code as weak symbols. By putting these earlier in the static library, they can then be picked up when only multiplication is used and they are overriden by the global definition in the existing file containing both multiplication and division code when division is needed. The patch also removes changes made to the FUNC_START and ARM_FUNC_START macros in r218124 since the intent was to put multiplication and division code into their own section in a later patch to achieve the same size optimization. That approach relied on specific section layout to ensure multiplication and division were not too far from the shared bit of code in order to the branches to be within range. Due to lack of guarantee regarding section layout, in particular with all the possibility of linker scripts, this approach was chosen instead. This patch keeps the two testcases that were posted by Tony Wang on the mailing list to implement this approach and adds a new one. 2018-12-19 Thomas Preud'homme <thomas.preudhomme@linaro.org> libgcc/ * /config/arm/lib1funcs.S (FUNC_START): Remove unused sp_section parameter and corresponding code. (ARM_FUNC_START): Likewise in both definitions. Also update footer comment about condition that need to match with gcc/config/arm/elf.h to also include libgcc/config/arm/t-arm. * config/arm/ieee754-df.S (muldf3): Also build it if L_arm_muldf3 is defined. Weakly define it in this case. * config/arm/ieee754-sf.S (mulsf3): Likewise with L_arm_mulsf3. * config/arm/t-elf (LIB1ASMFUNCS): Build _arm_muldf3.o and _arm_mulsf3.o before muldiv versions if targeting Thumb-1 only. Add comment to keep condition in sync with the one in libgcc/config/arm/lib1funcs.S and gcc/config/arm/elf.h. gcc/ * config/arm/elf.h: Update comment about condition that need to match with libgcc/config/arm/lib1funcs.S to also include libgcc/config/arm/t-arm. * doc/sourcebuild.texi (output-exists, output-exists-not): Rename subsubsection these directives are in to "Check for output files". Move scan-symbol to that section and add to it new scan-symbol-not directive. 2018-12-19 Tony Wang <tony.wang@arm.com> Thomas Preud'homme <thomas.preudhomme@linaro.org> gcc/testsuite/ * lib/lto.exp (lto-execute): Define output_file and testname_with_flags to same value as execname. (scan-symbol): Move and rename to ... * lib/gcc-dg.exp (scan-symbol-common): This. Adapt into a helper function returning true or false if a symbol is present. (scan-symbol): New procedure. (scan-symbol-not): Likewise. * gcc.target/arm/size-optimization-ieee-1.c: New testcase. * gcc.target/arm/size-optimization-ieee-2.c: Likewise. * gcc.target/arm/size-optimization-ieee-3.c: Likewise. From-SVN: r267282
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/ChangeLog15
-rw-r--r--libgcc/config/arm/ieee754-df.S16
-rw-r--r--libgcc/config/arm/ieee754-sf.S16
-rw-r--r--libgcc/config/arm/lib1funcs.S19
-rw-r--r--libgcc/config/arm/t-elf16
5 files changed, 67 insertions, 15 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 2075567..1879424 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,18 @@
+2018-12-19 Thomas Preud'homme <thomas.preudhomme@linaro.org>
+
+ * /config/arm/lib1funcs.S (FUNC_START): Remove unused sp_section
+ parameter and corresponding code.
+ (ARM_FUNC_START): Likewise in both definitions.
+ Also update footer comment about condition that need to match with
+ gcc/config/arm/elf.h to also include libgcc/config/arm/t-arm.
+ * config/arm/ieee754-df.S (muldf3): Also build it if L_arm_muldf3 is
+ defined. Weakly define it in this case.
+ * config/arm/ieee754-sf.S (mulsf3): Likewise with L_arm_mulsf3.
+ * config/arm/t-elf (LIB1ASMFUNCS): Build _arm_muldf3.o and
+ _arm_mulsf3.o before muldiv versions if targeting Thumb-1 only. Add
+ comment to keep condition in sync with the one in
+ libgcc/config/arm/lib1funcs.S and gcc/config/arm/elf.h.
+
2018-12-18 Wei Xiao <wei3.xiao@intel.com>
* config/i386/cpuinfo.c (get_intel_cpu): Handle cascadelake.
diff --git a/libgcc/config/arm/ieee754-df.S b/libgcc/config/arm/ieee754-df.S
index 480e33d..1765c5f 100644
--- a/libgcc/config/arm/ieee754-df.S
+++ b/libgcc/config/arm/ieee754-df.S
@@ -617,7 +617,18 @@ ARM_FUNC_ALIAS aeabi_l2d floatdidf
#endif /* L_addsubdf3 */
-#ifdef L_arm_muldivdf3
+#if defined(L_arm_muldf3) || defined(L_arm_muldivdf3)
+
+@ Define multiplication as weak in _arm_muldf3.o so that it can be overriden
+@ by the global definition in _arm_muldivdf3.o. This allows a program only
+@ using multiplication to take the weak definition which does not contain the
+@ division code. Programs using only division or both division and
+@ multiplication will pull _arm_muldivdf3.o from which both the multiplication
+@ and division are taken thanks to the override.
+#ifdef L_arm_muldf3
+WEAK muldf3
+WEAK aeabi_dmul
+#endif
ARM_FUNC_START muldf3
ARM_FUNC_ALIAS aeabi_dmul muldf3
@@ -870,6 +881,8 @@ LSYM(Lml_n):
FUNC_END aeabi_dmul
FUNC_END muldf3
+#ifdef L_arm_muldivdf3
+
ARM_FUNC_START divdf3
ARM_FUNC_ALIAS aeabi_ddiv divdf3
CFI_START_FUNCTION
@@ -1067,6 +1080,7 @@ LSYM(Ldv_s):
FUNC_END divdf3
#endif /* L_muldivdf3 */
+#endif /* L_arm_muldf3 || L_arm_muldivdf3 */
#ifdef L_arm_cmpdf2
diff --git a/libgcc/config/arm/ieee754-sf.S b/libgcc/config/arm/ieee754-sf.S
index 28e0d79..0b4d1ab 100644
--- a/libgcc/config/arm/ieee754-sf.S
+++ b/libgcc/config/arm/ieee754-sf.S
@@ -428,7 +428,18 @@ ARM_FUNC_ALIAS aeabi_l2f floatdisf
#endif /* L_addsubsf3 */
-#ifdef L_arm_muldivsf3
+#if defined(L_arm_mulsf3) || defined(L_arm_muldivsf3)
+
+@ Define multiplication as weak in _arm_mulsf3.o so that it can be overriden
+@ by the global definition in _arm_muldivsf3.o. This allows a program only
+@ using multiplication to take the weak definition which does not contain the
+@ division code. Programs using only division or both division and
+@ multiplication will pull _arm_muldivsf3.o from which both the multiplication
+@ and division are taken thanks to the override.
+#ifdef L_arm_mulsf3
+WEAK mulsf3
+WEAK aeabi_fmul
+#endif
ARM_FUNC_START mulsf3
ARM_FUNC_ALIAS aeabi_fmul mulsf3
@@ -613,6 +624,8 @@ LSYM(Lml_n):
FUNC_END aeabi_fmul
FUNC_END mulsf3
+#ifdef L_arm_muldivsf3
+
ARM_FUNC_START divsf3
ARM_FUNC_ALIAS aeabi_fdiv divsf3
CFI_START_FUNCTION
@@ -756,6 +769,7 @@ LSYM(Ldv_s):
FUNC_END divsf3
#endif /* L_muldivsf3 */
+#endif /* L_arm_mulsf3 || L_arm_muldivsf3 */
#ifdef L_arm_cmpsf2
diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S
index ff06d50..193fb25 100644
--- a/libgcc/config/arm/lib1funcs.S
+++ b/libgcc/config/arm/lib1funcs.S
@@ -359,12 +359,8 @@ SYM (\name):
#define THUMB_SYNTAX
#endif
-.macro FUNC_START name sp_section=
- .ifc \sp_section, function_section
- .section .text.__\name,"ax",%progbits
- .else
+.macro FUNC_START name
.text
- .endif
.globl SYM (__\name)
TYPE (__\name)
.align 0
@@ -390,8 +386,8 @@ SYM (\name):
#if defined(__thumb2__)
/* For Thumb-2 we build everything in thumb mode. */
-.macro ARM_FUNC_START name sp_section=
- FUNC_START \name \sp_section
+.macro ARM_FUNC_START name
+ FUNC_START \name
.syntax unified
.endm
#define EQUIV .thumb_set
@@ -422,12 +418,8 @@ _L__\name:
#ifdef NOT_ISA_TARGET_32BIT
#define EQUIV .thumb_set
#else
-.macro ARM_FUNC_START name sp_section=
- .ifc \sp_section, function_section
- .section .text.__\name,"ax",%progbits
- .else
+.macro ARM_FUNC_START name
.text
- .endif
.globl SYM (__\name)
TYPE (__\name)
.align 0
@@ -2169,7 +2161,8 @@ LSYM(Lchange_\register):
.endm
#ifndef __symbian__
-/* The condition here must match the one in gcc/config/arm/elf.h. */
+/* The condition here must match the one in gcc/config/arm/elf.h and
+ libgcc/config/arm/t-elf. */
#ifndef NOT_ISA_TARGET_32BIT
#include "ieee754-df.S"
#include "ieee754-sf.S"
diff --git a/libgcc/config/arm/t-elf b/libgcc/config/arm/t-elf
index 9e7a317..9da6cd3 100644
--- a/libgcc/config/arm/t-elf
+++ b/libgcc/config/arm/t-elf
@@ -1,3 +1,19 @@
+ifeq (,$(findstring __symbian__,$(shell $(gcc_compile_bare) -dM -E - </dev/null)))
+
+ARM_ISA:=$(findstring __ARM_ARCH_ISA_ARM,$(shell $(gcc_compile_bare) -dM -E - </dev/null))
+THUMB1_ISA:=$(findstring __ARM_ARCH_ISA_THUMB 1,$(shell $(gcc_compile_bare) -dM -E - </dev/null))
+
+# The condition here must match the one in gcc/config/arm/elf.h and
+# libgcc/config/arm/lib1funcs.S. _arm_muldf3 and _arm_mulsf3 must be included
+# first so that the weak multiplication symbols in the corresponding files are
+# chosen over the global symbols that _arm_muldivdf3 and _arm_muldivsf3
+# inclusion create when only multiplication is used, thus avoiding pulling in
+# useless division code.
+ifneq (__ARM_ARCH_ISA_THUMB 1,$(ARM_ISA)$(THUMB1_ISA))
+LIB1ASMFUNCS += _arm_muldf3 _arm_mulsf3
+endif
+endif # !__symbian__
+
# For most CPUs we have an assembly soft-float implementations.
# However this is not true for ARMv6M. Here we want to use the soft-fp C
# implementation. The soft-fp code is only build for ARMv6M. This pulls