From dc3deb8c81e99c0b8de46ed2cc536ffb406a3169 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Tue, 15 Aug 2017 12:37:58 -0700 Subject: [PATCH] Don't use vector arithmetic in generic arch_32 --- src/p448/arch_32/f_impl.h | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/p448/arch_32/f_impl.h b/src/p448/arch_32/f_impl.h index 72d7edd..c368788 100644 --- a/src/p448/arch_32/f_impl.h +++ b/src/p448/arch_32/f_impl.h @@ -10,37 +10,22 @@ #define LIMB_PLACE_VALUE(i) 28 void gf_add_RAW (gf out, const gf a, const gf b) { - for (unsigned int i=0; ilimb[0]); i++) { + for (unsigned int i=0; ilimb[0]); i++) { out->limb[i] = a->limb[i] + b->limb[i]; } - */ } void gf_sub_RAW (gf out, const gf a, const gf b) { - for (unsigned int i=0; ilimb[0]); i++) { + for (unsigned int i=0; ilimb[0]); i++) { out->limb[i] = a->limb[i] - b->limb[i]; } - */ } -void gf_bias (gf a, int amt) { +void gf_bias (gf a, int amt) { uint32_t co1 = ((1ull<<28)-1)*amt, co2 = co1-amt; - uint32x4_t lo = {co1,co1,co1,co1}, hi = {co2,co1,co1,co1}; - uint32x4_t *aa = (uint32x4_t*) a; - aa[0] += lo; - aa[1] += lo; - aa[2] += hi; - aa[3] += lo; + for (unsigned int i=0; ilimb[0]); i++) { + a->limb[i] += (i==sizeof(*a)/sizeof(a->limb[0])/2) ? co2 : co1; + } } void gf_weak_reduce (gf a) {