remove unused var

dev
MITSUNARI Shigeo 8 years ago
parent 8c74a0b0f0
commit 2c20ce0e34
  1. 2
      src/fp_generator.hpp
  2. 68
      src/fp_proto.hpp

@ -162,7 +162,6 @@ struct FpGenerator : Xbyak::CodeGenerator {
typedef int (*int2op)(uint64_t*, const uint64_t*);
void4u mul_;
uint3opI mulUnit_;
void *montRedRaw_;
void2op shr1_;
FpGenerator()
: CodeGenerator(4096 * 8)
@ -173,7 +172,6 @@ struct FpGenerator : Xbyak::CodeGenerator {
, isFullBit_(0)
, mul_(0)
, mulUnit_(0)
, montRedRaw_(0)
, shr1_(0)
{
useMulx_ = cpu_.has(Xbyak::util::Cpu::tBMI2);

@ -228,34 +228,27 @@ template<size_t N, class Tag>
const void4u DblSub<N, Tag>::f = DblSub<N, Tag>::func;
/*
z[N] <- Montgomery(x[N], y[N], p[N])
z[N] <- montRed(xy[N * 2], p[N])
REMARK : assume p[-1] = rp
*/
template<size_t N, class Tag = Gtag>
struct Mont {
static inline void func(Unit *z, const Unit *x, const Unit *y, const Unit *p)
struct MontRed {
static inline void func(Unit *z, const Unit *xy, const Unit *p)
{
#if 0
Unit xy[N * 2];
MulPre<N, Tag>::f(xy, x, y);
fpDbl_modMontC(z, xy, p);
#else
const Unit rp = p[-1];
Unit buf[N * 2 + 2];
Unit t[N * 2];
Unit buf[N * 2 + 1];
clearArray(t, N + 1, N * 2);
Unit *c = buf;
Mul_UnitPre<N, Tag>::f(c, x, y[0]); // x * y[0]
Unit q = c[0] * rp;
Unit t[N + 2];
Mul_UnitPre<N, Tag>::f(t, p, q); // p * q
t[N + 1] = 0; // always zero
c[N + 1] = AddPre<N + 1, Tag>::f(c, c, t);
Unit q = xy[0] * rp;
Mul_UnitPre<N, Tag>::f(t, p, q);
buf[N * 2] = AddPre<N * 2, Tag>::f(buf, xy, t);
c++;
for (size_t i = 1; i < N; i++) {
Mul_UnitPre<N, Tag>::f(t, x, y[i]);
c[N + 1] = AddPre<N + 1, Tag>::f(c, c, t);
q = c[0] * rp;
Mul_UnitPre<N, Tag>::f(t, p, q);
AddPre<N + 2, Tag>::f(c, c, t);
// QQQ
mpn_add_n((mp_limb_t*)c, (const mp_limb_t*)c, (const mp_limb_t*)t, N * 2 + 1 - i);
c++;
}
if (c[N]) {
@ -265,36 +258,42 @@ struct Mont {
memcpy(z, c, N * sizeof(Unit));
}
}
#endif
}
static const void4u f;
static const void3u f;
};
template<size_t N, class Tag>
const void4u Mont<N, Tag>::f = Mont<N, Tag>::func;
const void3u MontRed<N, Tag>::f = MontRed<N, Tag>::func;
/*
z[N] <- montRed(xy[N * 2], p[N])
z[N] <- Montgomery(x[N], y[N], p[N])
REMARK : assume p[-1] = rp
*/
template<size_t N, class Tag = Gtag>
struct MontRed {
static inline void func(Unit *z, const Unit *xy, const Unit *p)
struct Mont {
static inline void func(Unit *z, const Unit *x, const Unit *y, const Unit *p)
{
#if 0
Unit xy[N * 2];
MulPre<N, Tag>::f(xy, x, y);
MontRed<N, Tag>::f(z, xy, p);
#else
const Unit rp = p[-1];
Unit t[N * 2];
Unit buf[N * 2 + 1];
clearArray(t, N + 1, N * 2);
Unit buf[N * 2 + 2];
Unit *c = buf;
Unit q = xy[0] * rp;
Mul_UnitPre<N, Tag>::f(t, p, q);
buf[N * 2] = AddPre<N * 2, Tag>::f(buf, xy, t);
Mul_UnitPre<N, Tag>::f(c, x, y[0]); // x * y[0]
Unit q = c[0] * rp;
Unit t[N + 2];
Mul_UnitPre<N, Tag>::f(t, p, q); // p * q
t[N + 1] = 0; // always zero
c[N + 1] = AddPre<N + 1, Tag>::f(c, c, t);
c++;
for (size_t i = 1; i < N; i++) {
Mul_UnitPre<N, Tag>::f(t, x, y[i]);
c[N + 1] = AddPre<N + 1, Tag>::f(c, c, t);
q = c[0] * rp;
Mul_UnitPre<N, Tag>::f(t, p, q);
// QQQ
mpn_add_n((mp_limb_t*)c, (const mp_limb_t*)c, (const mp_limb_t*)t, N * 2 + 1 - i);
AddPre<N + 2, Tag>::f(c, c, t);
c++;
}
if (c[N]) {
@ -304,12 +303,13 @@ struct MontRed {
memcpy(z, c, N * sizeof(Unit));
}
}
#endif
}
static const void3u f;
static const void4u f;
};
template<size_t N, class Tag>
const void3u MontRed<N, Tag>::f = MontRed<N, Tag>::func;
const void4u Mont<N, Tag>::f = Mont<N, Tag>::func;
// z[N] <- Montgomery(x[N], x[N], p[N])
template<size_t N, class Tag = Gtag>

Loading…
Cancel
Save