about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--sysdeps/ieee754/dbl-64/mpa.c14
2 files changed, 7 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 607433b82f..cfddab03bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-02-16  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+	* sysdeps/ieee754/dbl-64/mpa.c (__sqr): Avoid using LIM in
+	loop termination condition.
+
 	* sysdeps/ieee754/dbl-64/mpa.c (__mul): Use intermediate
 	variable to calculate EZ.
 	(__sqr): Likewise.
diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c
index 9da4257263..1f60fa5a6d 100644
--- a/sysdeps/ieee754/dbl-64/mpa.c
+++ b/sysdeps/ieee754/dbl-64/mpa.c
@@ -747,12 +747,9 @@ __sqr (const mp_no *x, mp_no *y, int p)
       long lim = k / 2;
 
       if (k % 2 == 0)
-        {
-	  yk += X[lim] * X[lim];
-	  lim--;
-	}
+	yk += X[lim] * X[lim];
 
-      for (i = k - p, j = p; i <= lim; i++, j--)
+      for (i = k - p, j = p; i < j; i++, j--)
 	yk2 += X[i] * X[j];
 
       yk += 2.0 * yk2;
@@ -770,12 +767,9 @@ __sqr (const mp_no *x, mp_no *y, int p)
       long lim = k / 2;
 
       if (k % 2 == 0)
-        {
-	  yk += X[lim] * X[lim];
-	  lim--;
-	}
+	yk += X[lim] * X[lim];
 
-      for (i = 1, j = k - 1; i <= lim; i++, j--)
+      for (i = 1, j = k - 1; i < j; i++, j--)
 	yk2 += X[i] * X[j];
 
       yk += 2.0 * yk2;