about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/mpa.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/dbl-64/mpa.c')
-rw-r--r--sysdeps/ieee754/dbl-64/mpa.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c
index 25f52f65c6..9da4257263 100644
--- a/sysdeps/ieee754/dbl-64/mpa.c
+++ b/sysdeps/ieee754/dbl-64/mpa.c
@@ -693,15 +693,20 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
     }
   Z[k] = zk;
 
-  EZ = EX + EY;
+  /* Get the exponent sum into an intermediate variable.  This is a subtle
+     optimization, where given enough registers, all operations on the exponent
+     happen in registers and the result is written out only once into EZ.  */
+  int e = EX + EY;
+
   /* Is there a carry beyond the most significant digit?  */
   if (__glibc_unlikely (Z[1] == ZERO))
     {
       for (i = 1; i <= p; i++)
 	Z[i] = Z[i + 1];
-      EZ--;
+      e--;
     }
 
+  EZ = e;
   Z[0] = X[0] * Y[0];
 }
 
@@ -786,14 +791,20 @@ __sqr (const mp_no *x, mp_no *y, int p)
   /* Squares are always positive.  */
   Y[0] = 1.0;
 
-  EY = 2 * EX;
+  /* Get the exponent sum into an intermediate variable.  This is a subtle
+     optimization, where given enough registers, all operations on the exponent
+     happen in registers and the result is written out only once into EZ.  */
+  int e = EX * 2;
+
   /* Is there a carry beyond the most significant digit?  */
   if (__glibc_unlikely (Y[1] == ZERO))
     {
       for (i = 1; i <= p; i++)
 	Y[i] = Y[i + 1];
-      EY--;
+      e--;
     }
+
+  EY = e;
 }
 
 /* Invert *X and store in *Y.  Relative error bound: