aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/dbl-64/dla.h
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2019-11-08 11:32:00 -0800
committerVineet Gupta <vgupta@synopsys.com>2020-06-15 13:09:21 -0700
commite93c2643362c1b9f47952c126ae1bcac5ad20d0d (patch)
tree082c8857a0a871f97eb7c10dad6da0467641452c /sysdeps/ieee754/dbl-64/dla.h
parent27bf5e95061d05b780c629270003da2d9a1a2f52 (diff)
downloadglibc-e93c2643362c1b9f47952c126ae1bcac5ad20d0d.zip
glibc-e93c2643362c1b9f47952c126ae1bcac5ad20d0d.tar.gz
glibc-e93c2643362c1b9f47952c126ae1bcac5ad20d0d.tar.bz2
ieee754/dbl-64: Reduce the scope of temporary storage variables
This came to light when adding hard-flaot support to ARC glibc port without hardware sqrt support causing glibc build to fail: | ../sysdeps/ieee754/dbl-64/e_sqrt.c: In function '__ieee754_sqrt': | ../sysdeps/ieee754/dbl-64/e_sqrt.c:58:54: error: unused variable 'ty' [-Werror=unused-variable] | double y, t, del, res, res1, hy, z, zz, p, hx, tx, ty, s; The reason being EMULV() macro uses the hardware provided __builtin_fma() variant, leaving temporary variables 'p, hx, tx, hy, ty' unused hence compiler warning and ensuing error. The intent of the patch was to fix that error, but EMULV is pervasive and used fair bit indirectly via othe rmacros, hence this patch. Functionally it should not result in code gen changes and if at all those would be better since the scope of those temporaries is greatly reduced now Built tested with aarch64-linux-gnu arm-linux-gnueabi arm-linux-gnueabihf hppa-linux-gnu x86_64-linux-gnu arm-linux-gnueabihf riscv64-linux-gnu-rv64imac-lp64 riscv64-linux-gnu-rv64imafdc-lp64 powerpc-linux-gnu microblaze-linux-gnu nios2-linux-gnu hppa-linux-gnu Also as suggested by Joseph [1] used --strip and compared the libs with and w/o patch and they are byte-for-byte unchanged (with gcc 9). | for i in `find . -name libm-2.31.9000.so`; | do | echo $i; diff $i /SCRATCH/vgupta/gnu2/install/glibcs/$i ; echo $?; | done | ./aarch64-linux-gnu/lib64/libm-2.31.9000.so | 0 | ./arm-linux-gnueabi/lib/libm-2.31.9000.so | 0 | ./x86_64-linux-gnu/lib64/libm-2.31.9000.so | 0 | ./arm-linux-gnueabihf/lib/libm-2.31.9000.so | 0 | ./riscv64-linux-gnu-rv64imac-lp64/lib64/lp64/libm-2.31.9000.so | 0 | ./riscv64-linux-gnu-rv64imafdc-lp64/lib64/lp64/libm-2.31.9000.so | 0 | ./powerpc-linux-gnu/lib/libm-2.31.9000.so | 0 | ./microblaze-linux-gnu/lib/libm-2.31.9000.so | 0 | ./nios2-linux-gnu/lib/libm-2.31.9000.so | 0 | ./hppa-linux-gnu/lib/libm-2.31.9000.so | 0 | ./s390x-linux-gnu/lib64/libm-2.31.9000.so [1] https://sourceware.org/pipermail/libc-alpha/2019-November/108267.html
Diffstat (limited to 'sysdeps/ieee754/dbl-64/dla.h')
-rw-r--r--sysdeps/ieee754/dbl-64/dla.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/sysdeps/ieee754/dbl-64/dla.h b/sysdeps/ieee754/dbl-64/dla.h
index 1bbad16..fd58664 100644
--- a/sysdeps/ieee754/dbl-64/dla.h
+++ b/sysdeps/ieee754/dbl-64/dla.h
@@ -67,13 +67,15 @@
/* storage variables of type double. */
#ifdef DLA_FMS
-# define EMULV(x, y, z, zz, p, hx, tx, hy, ty) \
+# define EMULV(x, y, z, zz) \
z = x * y; zz = DLA_FMS (x, y, z);
#else
-# define EMULV(x, y, z, zz, p, hx, tx, hy, ty) \
- p = CN * (x); hx = ((x) - p) + p; tx = (x) - hx; \
- p = CN * (y); hy = ((y) - p) + p; ty = (y) - hy; \
- z = (x) * (y); zz = (((hx * hy - z) + hx * ty) + tx * hy) + tx * ty;
+# define EMULV(x, y, z, zz) \
+ ({ __typeof__ (x) __p, hx, tx, hy, ty; \
+ __p = CN * (x); hx = ((x) - __p) + __p; tx = (x) - hx; \
+ __p = CN * (y); hy = ((y) - __p) + __p; ty = (y) - hy; \
+ z = (x) * (y); zz = (((hx * hy - z) + hx * ty) + tx * hy) + tx * ty; \
+ })
#endif
@@ -83,13 +85,15 @@
/* storage variables of type double. */
#ifdef DLA_FMS
-# define MUL12(x,y,z,zz,p,hx,tx,hy,ty,q) \
- EMULV(x,y,z,zz,p,hx,tx,hy,ty)
+# define MUL12(x, y, z, zz) \
+ EMULV(x, y, z, zz)
#else
-# define MUL12(x,y,z,zz,p,hx,tx,hy,ty,q) \
- p=CN*(x); hx=((x)-p)+p; tx=(x)-hx; \
- p=CN*(y); hy=((y)-p)+p; ty=(y)-hy; \
- p=hx*hy; q=hx*ty+tx*hy; z=p+q; zz=((p-z)+q)+tx*ty;
+# define MUL12(x, y, z, zz) \
+ ({ __typeof__ (x) __p, hx, tx, hy, ty, __q; \
+ __p=CN*(x); hx=((x)-__p)+__p; tx=(x)-hx; \
+ __p=CN*(y); hy=((y)-__p)+__p; ty=(y)-hy; \
+ __p=hx*hy; __q=hx*ty+tx*hy; z=__p+__q; zz=((__p-z)+__q)+tx*ty; \
+ })
#endif
@@ -125,8 +129,8 @@
/* are assumed to be double-length numbers. p,hx,tx,hy,ty,q,c,cc are */
/* temporary storage variables of type double. */
-#define MUL2(x, xx, y, yy, z, zz, p, hx, tx, hy, ty, q, c, cc) \
- MUL12 (x, y, c, cc, p, hx, tx, hy, ty, q) \
+#define MUL2(x, xx, y, yy, z, zz, c, cc) \
+ MUL12 (x, y, c, cc); \
cc = ((x) * (yy) + (xx) * (y)) + cc; z = c + cc; zz = (c - z) + cc;
@@ -136,8 +140,8 @@
/* are assumed to be double-length numbers. p,hx,tx,hy,ty,q,c,cc,u,uu */
/* are temporary storage variables of type double. */
-#define DIV2(x,xx,y,yy,z,zz,p,hx,tx,hy,ty,q,c,cc,u,uu) \
- c=(x)/(y); MUL12(c,y,u,uu,p,hx,tx,hy,ty,q) \
+#define DIV2(x, xx, y, yy, z, zz, c, cc, u, uu) \
+ c=(x)/(y); MUL12(c,y,u,uu); \
cc=(((((x)-u)-uu)+(xx))-c*(yy))/(y); z=c+cc; zz=(c-z)+cc;