aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-07 16:35:17 +0000
committerlloyd <[email protected]>2008-09-07 16:35:17 +0000
commit8713c3cee77a9a1802e41038fc4bfced89260a64 (patch)
treed1a5e7aa798bb822f8dd34f432bd627f1116005c /src
parent2b6eb00977cc71432ea3a18b51c60eff4c086fbe (diff)
Inline bigint_cmp in bigint_monty_redc (using goto, the horror; I'm basically
prototyping and testing the x86-64 assembly version in C) According to most profiles, bigint_monty_redc alone is responsible for 30%-50% of RSA, DSA, and DH benchmarks. So it seems worth tinkering with a bit.
Diffstat (limited to 'src')
-rw-r--r--src/mp_monty.cpp37
1 files changed, 10 insertions, 27 deletions
diff --git a/src/mp_monty.cpp b/src/mp_monty.cpp
index 0658deb42..57c29137f 100644
--- a/src/mp_monty.cpp
+++ b/src/mp_monty.cpp
@@ -48,7 +48,7 @@ void bigint_monty_redc(word z[], u32bit z_size,
}
}
-#if 1
+#if 0
if(bigint_cmp(z + x_size, x_size + 1, x, x_size) >= 0)
bigint_sub2(z + x_size, x_size + 1, x, x_size);
#else
@@ -151,13 +151,10 @@ s32bit bigint_cmp(const word x[], u32bit x_size,
*/
- print
-
- if(z[2*x_size + 1])
+ if(z[x_size + x_size])
{
assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) > 0);
- bigint_sub2(z + x_size, x_size + 1, x, x_size);
- return;
+ goto do_sub;
}
for(u32bit j = x_size; j > 0; --j)
@@ -165,38 +162,24 @@ s32bit bigint_cmp(const word x[], u32bit x_size,
if(z[x_size + j - 1] > x[j-1])
{
assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) > 0);
- bigint_sub2(z + x_size, x_size + 1, x, x_size);
- return;
+ goto do_sub;
}
if(z[x_size + j - 1] < x[j-1])
{
- if(bigint_cmp(z + x_size, x_size + 1, x, x_size) >= 0)
- {
- printf("on j=%d\n", j);
-
- printf("\nz=");
- for(u32bit i = 0; i != x_size+1; i++)
- printf("%08llX", z[x_size+i]);
- printf("\n");
-
- printf("x=");
- printf("00000000");
- for(u32bit i = 0; i != x_size; i++)
- printf("%08llX", x[i]);
- printf("\n");
-
- printf("cmp=%d\n", bigint_cmp(z + x_size, x_size + 1, x, x_size));
- }
-
assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) < 0);
- return;
+ goto done;
}
}
assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) == 0);
+
+do_sub:
bigint_sub2(z + x_size, x_size + 1, x, x_size);
+done:
+ return;
+
#endif
}