summaryrefslogtreecommitdiff
path: root/mpn
diff options
context:
space:
mode:
authortege <tege@gmplib.org>2001-11-22 21:17:04 +0100
committertege <tege@gmplib.org>2001-11-22 21:17:04 +0100
commitc3263dce6ead688db35eb1cded0e43d8f9f36cbc (patch)
tree47f1a5961ebde5e868d731fdea886cb246b62e8f /mpn
parentc5ad3c3908a210d21cc7c154170ff893465efb91 (diff)
downloadgmp-c3263dce6ead688db35eb1cded0e43d8f9f36cbc.tar.gz
Fix logic for more_carries scalar loop.
Diffstat (limited to 'mpn')
-rw-r--r--mpn/cray/ieee/addmul_1.c9
-rw-r--r--mpn/cray/ieee/submul_1.c9
2 files changed, 10 insertions, 8 deletions
diff --git a/mpn/cray/ieee/addmul_1.c b/mpn/cray/ieee/addmul_1.c
index 51a7febb0..53ab741c5 100644
--- a/mpn/cray/ieee/addmul_1.c
+++ b/mpn/cray/ieee/addmul_1.c
@@ -58,8 +58,8 @@ mpn_addmul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl)
c1 = ((s0 & r) | ((s0 | r) & ~s1)) >> 63;
cy[i] = c0 + c1;
}
- /* Carry add loop. Add the carry vector cy[] to the raw sum rp[] and
- store the new sum back to rp[0]. */
+ /* Carry add loop. Add the carry vector cy[] to the raw result rp[] and
+ store the new result back to rp[]. */
more_carries = 0;
#pragma _CRI ivdep
for (i = 1; i < n; i++)
@@ -75,12 +75,13 @@ mpn_addmul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl)
if (more_carries)
{
mp_limb_t cyrec = 0;
- /* Look for places where rp[k] is zero and cy[k-1] is non-zero.
+ /* Look for places where rp[k] == 0 and cy[k-1] == 1 or
+ rp[k] == 1 and cy[k-1] == 2.
These are where we got a recurrency carry. */
for (i = 1; i < n; i++)
{
r = rp[i];
- c0 = (r == 0 && cy[i - 1] != 0);
+ c0 = r < cy[i - 1];
s0 = r + cyrec;
rp[i] = s0;
c1 = (r & ~s0) >> 63;
diff --git a/mpn/cray/ieee/submul_1.c b/mpn/cray/ieee/submul_1.c
index 12e259d3b..d7dccfba3 100644
--- a/mpn/cray/ieee/submul_1.c
+++ b/mpn/cray/ieee/submul_1.c
@@ -58,8 +58,8 @@ mpn_submul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl)
c1 = ((s1 & s0) | ((s1 | s0) & ~r)) >> 63;
cy[i] = c0 + c1;
}
- /* Carry add loop. Add the carry vector cy[] to the raw sum rp[] and
- store the new sum back to rp[0]. */
+ /* Carry subtract loop. Subtract the carry vector cy[] from the raw result
+ rp[] and store the new result back to rp[]. */
more_carries = 0;
#pragma _CRI ivdep
for (i = 1; i < n; i++)
@@ -75,12 +75,13 @@ mpn_submul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl)
if (more_carries)
{
mp_limb_t cyrec = 0;
- /* Look for places where rp[k] is zero and cy[k-1] is non-zero.
+ /* Look for places where rp[k] == ~0 and cy[k-1] == 1 or
+ rp[k] == ~1 and cy[k-1] == 2.
These are where we got a recurrency carry. */
for (i = 1; i < n; i++)
{
r = rp[i];
- c0 = (~r == 0 && cy[i - 1] != 0);
+ c0 = ~r < cy[i - 1];
s0 = r - cyrec;
rp[i] = s0;
c1 = (s0 & ~r) >> 63;