if (rhat < b)
goto again;
}
-#define MUL_RSUB_CARRY_2_STAGE2
+// don't define here, allowing easily testing all options by passing -D...
+// #define MUL_RSUB_CARRY_2_STAGE2
#ifdef ORIGINAL
// Multiply and subtract.
k = 0;
un[i + j] = (uint32_t)result;
}
bool need_fixup = carry != 0;
+#elif defined(MADDED_SUBFE)
+ (void)p; // shut up unused variable warning
+
+ // Multiply and subtract.
+ uint32_t carry = 0;
+ uint32_t product[n + 1];
+ // VL = n + 1
+ // sv.madded product.v, vn.v, qhat.s, carry.s
+ for (int i = 0; i <= n; i++)
+ {
+ uint32_t vn_v = i < n ? vn[i] : 0;
+ uint64_t value = (uint64_t)vn_v * (uint64_t)qhat + carry;
+ carry = (uint32_t)(value >> 32);
+ product[i] = (uint32_t)value;
+ }
+ bool ca = true;
+ uint32_t *un_j = &un[j];
+ // VL = n + 1
+ // sv.subfe un_j.v, product.v, un_j.v
+ for (int i = 0; i <= n; i++)
+ {
+ uint64_t value = (uint64_t)~product[i] + (uint64_t)un_j[i] + ca;
+ ca = value >> 32 != 0;
+ un_j[i] = value;
+ }
+ bool need_fixup = !ca;
#else
#error need to choose one of the algorithm options; e.g. -DORIGINAL
#endif