@@ -62,6 +62,19 @@ inline VecType CardMinusOne<uint32_t>(uint32_t q)
62
62
return (q == F3) ? F3_MINUS_ONE_U32 : F4_MINUS_ONE_U32;
63
63
}
64
64
65
+ template <typename T>
66
+ inline VecType GetLowHalf (VecType x, T q)
67
+ {
68
+ return (q == F3) ? BLEND8 (ZERO, x, MASK8_LO) : BLEND16 (ZERO, x, 0x55 );
69
+ }
70
+
71
+ template <typename T>
72
+ inline VecType GetHighHalf (VecType x, T q)
73
+ {
74
+ return (q == F3) ? BLEND8 (ZERO, SHIFTR (x, 1 ), MASK8_LO)
75
+ : BLEND16 (ZERO, SHIFTR (x, 2 ), 0x55 );
76
+ }
77
+
65
78
/* ================= Basic Operations ================= */
66
79
67
80
/* *
@@ -123,10 +136,8 @@ template <typename T>
123
136
inline VecType ModMul (VecType x, VecType y, T q)
124
137
{
125
138
const VecType res = Mul<T>(x, y);
126
- const VecType lo =
127
- (q == F3) ? BLEND8 (ZERO, res, MASK8_LO) : BLEND16 (ZERO, res, 0x55 );
128
- const VecType hi = (q == F3) ? BLEND8 (ZERO, SHIFTR (res, 1 ), MASK8_LO)
129
- : BLEND16 (ZERO, SHIFTR (res, 2 ), 0x55 );
139
+ const VecType lo = GetLowHalf (res, q);
140
+ const VecType hi = GetHighHalf (res, q);
130
141
return ModSub (lo, hi, q);
131
142
}
132
143
0 commit comments