[Libre-soc-dev] SVP64 Vectorised add-carry => big int add
lkcl
luke.leighton at gmail.com
Mon Apr 18 17:10:22 BST 2022
On Mon, Apr 18, 2022 at 4:32 PM lkcl <luke.leighton at gmail.com> wrote:
> any clues as to why?
this is about the oddest multiply operation i could imagine... but it works.
whhyyyy? how could it be turned into a proper double-width
mul-and-subtract? what information needs to be transferred
from the first loop to the second? is it as simple as checking
if un[i+j] < (p&0xffffffff)? that would cause a carry-borrow into
phi, which could be compensated for, couldn't it?
// double-width multiply with strange subtract only on bottom half
for (i = 0; i < n; i++) {
unsigned long long p = qhat*vn[i];
plo[i] = un[i+j] - (p&0xffffffffLL);
phi[i] = p >> 32;
}
for (i = 0; i < n; i++) {
t = plo[i] - k; // subtract previous carry
un[i+j] = (t & 0xffffffffLL);
k = phi[i] - (t >> 32); // take top-halves for new carry
}
More information about the Libre-soc-dev
mailing list