From 7f2e6e89fa86e15096f02e02a1af25a6f05ddcc0 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 4 Oct 2012 10:53:59 -0700 Subject: Extract __mul from sysdeps/ieee754/dbl-64/mpa.c Compile __mul with both AVX and FMA4. Compile other functions only with AVX since they don't benefit from FMA4. --- ChangeLog.pr14654 | 32 ++++++++++++++++++++++++++++ sysdeps/ieee754/dbl-64/mpa.c | 6 ++++++ sysdeps/x86_64/fpu/multiarch/Makefile | 7 +++--- sysdeps/x86_64/fpu/multiarch/e_atan2-fma4.c | 8 +++---- sysdeps/x86_64/fpu/multiarch/e_log-fma4.c | 6 +++--- sysdeps/x86_64/fpu/multiarch/mpa-avx.c | 2 +- sysdeps/x86_64/fpu/multiarch/mpa-fma4.c | 12 ----------- sysdeps/x86_64/fpu/multiarch/mpatan-fma4.c | 6 +++--- sysdeps/x86_64/fpu/multiarch/mpatan2-fma4.c | 4 ++-- sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c | 6 +++--- sysdeps/x86_64/fpu/multiarch/mplog-fma4.c | 4 ++-- sysdeps/x86_64/fpu/multiarch/mpsqrt-fma4.c | 4 ++-- sysdeps/x86_64/fpu/multiarch/mptan-fma4.c | 2 +- sysdeps/x86_64/fpu/multiarch/mul-avx.c | 8 +++++++ sysdeps/x86_64/fpu/multiarch/mul-fma4.c | 8 +++++++ sysdeps/x86_64/fpu/multiarch/s_atan-fma4.c | 6 +++--- sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c | 4 ++-- sysdeps/x86_64/fpu/multiarch/sincos32-fma4.c | 6 +++--- sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c | 6 +++--- sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c | 6 +++--- 20 files changed, 93 insertions(+), 50 deletions(-) create mode 100644 ChangeLog.pr14654 delete mode 100644 sysdeps/x86_64/fpu/multiarch/mpa-fma4.c create mode 100644 sysdeps/x86_64/fpu/multiarch/mul-avx.c create mode 100644 sysdeps/x86_64/fpu/multiarch/mul-fma4.c diff --git a/ChangeLog.pr14654 b/ChangeLog.pr14654 new file mode 100644 index 0000000000..bb5e25f795 --- /dev/null +++ b/ChangeLog.pr14654 @@ -0,0 +1,32 @@ +2012-10-04 H.J. Lu + + [BZ #14654] + * sysdeps/ieee754/dbl-64/mpa.c: Don't export __mul if NO___MUL + is defined. Only export __mul if __mul is defined. + * sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines): + Replace mpa-fma4 with mul-fma4. Add mul-avx. + (CFLAGS-mpa-fma4.c): Removed. + (CFLAGS-mul-fma4.c): New. + (CFLAGS-mul-avx.c): Likewise. + * sysdeps/x86_64/fpu/multiarch/e_atan2-fma4.c (__add): Defined + to __add_avx. + (__dbl_mp): Defined to __dbl_mp_avx. + (__dvd): Defined to __dvd_avx. + (__sub): Defined to __sub_avx. + * sysdeps/x86_64/fpu/multiarch/e_log-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mpatan-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mpatan2-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mplog-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mpsqrt-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mptan-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/s_atan-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/sincos32-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/mpa-avx.c (__mul): Removed. + (NO___MUL): New. + * sysdeps/x86_64/fpu/multiarch/mpa-fma4.c: Removed. + * sysdeps/x86_64/fpu/multiarch/mul-avx.c: New file. + * sysdeps/x86_64/fpu/multiarch/mul-fma4.c: Likewise. diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c index 7e0ee445c6..4a92ada687 100644 --- a/sysdeps/ieee754/dbl-64/mpa.c +++ b/sysdeps/ieee754/dbl-64/mpa.c @@ -51,6 +51,7 @@ # define SECTION #endif +#ifndef __mul #ifndef NO___ACR /* mcr() compares the sizes of the mantissas of two multiple precision */ /* numbers. Mantissas are compared regardless of the signs of the */ @@ -430,8 +431,10 @@ __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) { else Z[0] = ZERO; } } +#endif +#ifndef NO___MUL /* Multiply two multiple precision numbers. *z is set to *x * *y. x&y */ /* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is */ /* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp. */ @@ -471,8 +474,10 @@ __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) { Z[0] = X[0] * Y[0]; } +#endif +#ifndef __mul /* Invert a multiple precision number. Set *y = 1 / *x. */ /* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3, */ /* 2.001*r**(1-p) for p>3. */ @@ -520,3 +525,4 @@ __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) { if (X[0] == ZERO) Z[0] = ZERO; else {__inv(y,&w,p); __mul(x,&w,z,p);} } +#endif diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 12b0526e50..b3e5658464 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -5,7 +5,7 @@ libm-sysdep_routines += s_floor-c s_ceil-c s_floorf-c s_ceilf-c \ ifeq ($(have-mfma4),yes) libm-sysdep_routines += e_exp-fma4 e_log-fma4 e_pow-fma4 s_atan-fma4 \ e_asin-fma4 e_atan2-fma4 s_sin-fma4 s_tan-fma4 \ - mplog-fma4 mpa-fma4 slowexp-fma4 slowpow-fma4 \ + mplog-fma4 mul-fma4 slowexp-fma4 slowpow-fma4 \ sincos32-fma4 doasin-fma4 dosincos-fma4 \ halfulp-fma4 mpexp-fma4 \ mpatan2-fma4 mpatan-fma4 mpsqrt-fma4 mptan-fma4 @@ -18,13 +18,13 @@ CFLAGS-e_exp-fma4.c = -mfma4 CFLAGS-e_log-fma4.c = -mfma4 CFLAGS-e_pow-fma4.c = -mfma4 CFLAGS-halfulp-fma4.c = -mfma4 -CFLAGS-mpa-fma4.c = -mfma4 CFLAGS-mpatan-fma4.c = -mfma4 CFLAGS-mpatan2-fma4.c = -mfma4 CFLAGS-mpexp-fma4.c = -mfma4 CFLAGS-mplog-fma4.c = -mfma4 CFLAGS-mpsqrt-fma4.c = -mfma4 CFLAGS-mptan-fma4.c = -mfma4 +CFLAGS-mul-fma4.c = -mfma4 CFLAGS-s_atan-fma4.c = -mfma4 CFLAGS-sincos32-fma4.c = -mfma4 CFLAGS-slowexp-fma4.c = -mfma4 @@ -37,7 +37,7 @@ ifeq ($(config-cflags-sse2avx),yes) libm-sysdep_routines += e_exp-avx e_log-avx s_atan-avx \ e_atan2-avx s_sin-avx s_tan-avx \ mplog-avx mpa-avx slowexp-avx \ - mpexp-avx + mpexp-avx mul-avx CFLAGS-e_atan2-avx.c = -msse2avx -DSSE2AVX CFLAGS-e_exp-avx.c = -msse2avx -DSSE2AVX @@ -45,6 +45,7 @@ CFLAGS-e_log-avx.c = -msse2avx -DSSE2AVX CFLAGS-mpa-avx.c = -msse2avx -DSSE2AVX CFLAGS-mpexp-avx.c = -msse2avx -DSSE2AVX CFLAGS-mplog-avx.c = -msse2avx -DSSE2AVX +CFLAGS-mul-avx.c = -msse2avx -DSSE2AVX CFLAGS-s_atan-avx.c = -msse2avx -DSSE2AVX CFLAGS-s_sin-avx.c = -msse2avx -DSSE2AVX CFLAGS-slowexp-avx.c = -msse2avx -DSSE2AVX diff --git a/sysdeps/x86_64/fpu/multiarch/e_atan2-fma4.c b/sysdeps/x86_64/fpu/multiarch/e_atan2-fma4.c index f4e986293e..f8c8eb6f0a 100644 --- a/sysdeps/x86_64/fpu/multiarch/e_atan2-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/e_atan2-fma4.c @@ -1,10 +1,10 @@ #define __ieee754_atan2 __ieee754_atan2_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 -#define __dvd __dvd_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx +#define __dvd __dvd_avx #define __mpatan2 __mpatan2_fma4 #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/e_log-fma4.c b/sysdeps/x86_64/fpu/multiarch/e_log-fma4.c index a2346cc618..d4b1819278 100644 --- a/sysdeps/x86_64/fpu/multiarch/e_log-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/e_log-fma4.c @@ -1,8 +1,8 @@ #define __ieee754_log __ieee754_log_fma4 #define __mplog __mplog_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 -#define __sub __sub_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/mpa-avx.c b/sysdeps/x86_64/fpu/multiarch/mpa-avx.c index a92dbedc05..90d93e87f9 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpa-avx.c +++ b/sysdeps/x86_64/fpu/multiarch/mpa-avx.c @@ -1,5 +1,4 @@ #define __add __add_avx -#define __mul __mul_avx #define __sub __sub_avx #define __dbl_mp __dbl_mp_avx #define __dvd __dvd_avx @@ -7,6 +6,7 @@ #define NO___CPY 1 #define NO___MP_DBL 1 #define NO___ACR 1 +#define NO___MUL 1 #define SECTION __attribute__ ((section (".text.avx"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c b/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c deleted file mode 100644 index f8ed8f3464..0000000000 --- a/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c +++ /dev/null @@ -1,12 +0,0 @@ -#define __add __add_fma4 -#define __mul __mul_fma4 -#define __sub __sub_fma4 -#define __dbl_mp __dbl_mp_fma4 -#define __dvd __dvd_fma4 - -#define NO___CPY 1 -#define NO___MP_DBL 1 -#define NO___ACR 1 -#define SECTION __attribute__ ((section (".text.fma4"))) - -#include diff --git a/sysdeps/x86_64/fpu/multiarch/mpatan-fma4.c b/sysdeps/x86_64/fpu/multiarch/mpatan-fma4.c index fbd3bd49a2..a665e6844d 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpatan-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mpatan-fma4.c @@ -1,9 +1,9 @@ #define __mpatan __mpatan_fma4 -#define __add __add_fma4 -#define __dvd __dvd_fma4 +#define __add __add_avx +#define __dvd __dvd_avx #define __mpsqrt __mpsqrt_fma4 #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define AVOID_MPATAN_H 1 #define SECTION __attribute__ ((section (".text.fma4"))) diff --git a/sysdeps/x86_64/fpu/multiarch/mpatan2-fma4.c b/sysdeps/x86_64/fpu/multiarch/mpatan2-fma4.c index e6e44d49b0..c41b887129 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpatan2-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mpatan2-fma4.c @@ -1,6 +1,6 @@ #define __mpatan2 __mpatan2_fma4 -#define __add __add_fma4 -#define __dvd __dvd_fma4 +#define __add __add_avx +#define __dvd __dvd_avx #define __mpatan __mpatan_fma4 #define __mpsqrt __mpsqrt_fma4 #define __mul __mul_fma4 diff --git a/sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c b/sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c index 07ca6e9ad0..5950aef1af 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c @@ -1,7 +1,7 @@ #define __mpexp __mpexp_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 -#define __dvd __dvd_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx +#define __dvd __dvd_avx #define __mul __mul_fma4 #define AVOID_MPEXP_H 1 #define SECTION __attribute__ ((section (".text.fma4"))) diff --git a/sysdeps/x86_64/fpu/multiarch/mplog-fma4.c b/sysdeps/x86_64/fpu/multiarch/mplog-fma4.c index b4733118d7..dd1f46eaa6 100644 --- a/sysdeps/x86_64/fpu/multiarch/mplog-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mplog-fma4.c @@ -1,8 +1,8 @@ #define __mplog __mplog_fma4 -#define __add __add_fma4 +#define __add __add_avx #define __mpexp __mpexp_fma4 #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/mpsqrt-fma4.c b/sysdeps/x86_64/fpu/multiarch/mpsqrt-fma4.c index f8a1ba2d92..85996db9de 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpsqrt-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mpsqrt-fma4.c @@ -1,7 +1,7 @@ #define __mpsqrt __mpsqrt_fma4 -#define __dbl_mp __dbl_mp_fma4 +#define __dbl_mp __dbl_mp_avx #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define AVOID_MPSQRT_H 1 #define SECTION __attribute__ ((section (".text.fma4"))) diff --git a/sysdeps/x86_64/fpu/multiarch/mptan-fma4.c b/sysdeps/x86_64/fpu/multiarch/mptan-fma4.c index fb4a9d48ca..87e4dec54d 100644 --- a/sysdeps/x86_64/fpu/multiarch/mptan-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mptan-fma4.c @@ -1,6 +1,6 @@ #define __mptan __mptan_fma4 #define __c32 __c32_fma4 -#define __dvd __dvd_fma4 +#define __dvd __dvd_avx #define __mpranred __mpranred_fma4 #define SECTION __attribute__ ((section (".text.fma4"))) diff --git a/sysdeps/x86_64/fpu/multiarch/mul-avx.c b/sysdeps/x86_64/fpu/multiarch/mul-avx.c new file mode 100644 index 0000000000..b4f0477b6f --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/mul-avx.c @@ -0,0 +1,8 @@ +#define __mul __mul_avx + +#define NO___CPY 1 +#define NO___MP_DBL 1 +#define NO___ACR 1 +#define SECTION __attribute__ ((section (".text.avx"))) + +#include diff --git a/sysdeps/x86_64/fpu/multiarch/mul-fma4.c b/sysdeps/x86_64/fpu/multiarch/mul-fma4.c new file mode 100644 index 0000000000..230b0e5c4a --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/mul-fma4.c @@ -0,0 +1,8 @@ +#define __mul __mul_fma4 + +#define NO___CPY 1 +#define NO___MP_DBL 1 +#define NO___ACR 1 +#define SECTION __attribute__ ((section (".text.fma4"))) + +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_atan-fma4.c b/sysdeps/x86_64/fpu/multiarch/s_atan-fma4.c index 9e83e6cdab..2b3516a077 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_atan-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/s_atan-fma4.c @@ -1,9 +1,9 @@ #define atan __atan_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx #define __mpatan __mpatan_fma4 #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c b/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c index a805440b46..39556a80fa 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c @@ -1,8 +1,8 @@ #define tan __tan_fma4 -#define __dbl_mp __dbl_mp_fma4 +#define __dbl_mp __dbl_mp_avx #define __mpranred __mpranred_fma4 #define __mptan __mptan_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/sincos32-fma4.c b/sysdeps/x86_64/fpu/multiarch/sincos32-fma4.c index ebbfa18cca..14b9d098a0 100644 --- a/sysdeps/x86_64/fpu/multiarch/sincos32-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/sincos32-fma4.c @@ -6,10 +6,10 @@ #define __mpcos __mpcos_fma4 #define __mpcos1 __mpcos1_fma4 #define __mpranred __mpranred_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c b/sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c index 3bcde84233..df90752356 100644 --- a/sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c @@ -1,9 +1,9 @@ #define __slowexp __slowexp_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx #define __mpexp __mpexp_fma4 #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define SECTION __attribute__ ((section (".text.fma4"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c b/sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c index 69d69823bb..162aaa5d5c 100644 --- a/sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c @@ -1,10 +1,10 @@ #define __slowpow __slowpow_fma4 -#define __add __add_fma4 -#define __dbl_mp __dbl_mp_fma4 +#define __add __add_avx +#define __dbl_mp __dbl_mp_avx #define __mpexp __mpexp_fma4 #define __mplog __mplog_fma4 #define __mul __mul_fma4 -#define __sub __sub_fma4 +#define __sub __sub_avx #define __halfulp __halfulp_fma4 #define SECTION __attribute__ ((section (".text.fma4"))) -- cgit v1.2.3