Use the correct type for the cmov mask

This commit is contained in:
Frank Denis 2017-11-01 19:37:34 +01:00
parent 8d5b6b1fc9
commit f57fcb9c26

View File

@ -176,6 +176,8 @@ fe_neg(fe h, const fe f)
static void static void
fe_cmov(fe f, const fe g, unsigned int b) fe_cmov(fe f, const fe g, unsigned int b)
{ {
const uint32_t mask = (uint32_t) (-(int32_t) b);
int32_t f0 = f[0]; int32_t f0 = f[0];
int32_t f1 = f[1]; int32_t f1 = f[1];
int32_t f2 = f[2]; int32_t f2 = f[2];
@ -198,17 +200,16 @@ fe_cmov(fe f, const fe g, unsigned int b)
int32_t x8 = f8 ^ g[8]; int32_t x8 = f8 ^ g[8];
int32_t x9 = f9 ^ g[9]; int32_t x9 = f9 ^ g[9];
b = (unsigned int) (-(int) b); x0 &= mask;
x0 &= b; x1 &= mask;
x1 &= b; x2 &= mask;
x2 &= b; x3 &= mask;
x3 &= b; x4 &= mask;
x4 &= b; x5 &= mask;
x5 &= b; x6 &= mask;
x6 &= b; x7 &= mask;
x7 &= b; x8 &= mask;
x8 &= b; x9 &= mask;
x9 &= b;
f[0] = f0 ^ x0; f[0] = f0 ^ x0;
f[1] = f1 ^ x1; f[1] = f1 ^ x1;
f[2] = f2 ^ x2; f[2] = f2 ^ x2;