[Libre-soc-dev] SVP64 Vectorised add-carry => big int add

lkcl luke.leighton at gmail.com
Wed Apr 20 14:18:45 BST 2022



On April 19, 2022 7:57:03 PM UTC, lkcl <luke.leighton at gmail.com> wrote:

>>One other thing we'd want is a unsigned * signed version of mule
>>(muluse?),
>>for bigint multiplication by a signed 64-bit number,

ah.  ha :)

https://github.com/hcs0/Hackers-Delight/blob/master/mulmns.c.txt

the "whoops" is of course, it is the 1st mul that would need to be signed, Knuth's algorithm does post-correction by checking the operands MSB and what the frick is *this* doing? :)

   if ((short)u[m - 1] < 0) { // check bigint MSB
      b = 0;                    // Initialize borrow.
      for (j = 0; j < n; j++) {
         t = w[j + m] - v[j] - b;
         w[j + m] = t;
         b = t >> 31;
      }
   }

it says in the comment "subtracting v*2**16m if u < 0" the u<0 i get, but setting b=MSB of t (t>>31), huhn?

that would be something like subMSBeo:

     sub[0:127] = RA - RB - CA
     RT = sub[64:127] # LO half
     CA = sub[0] # MSB

which is the weirdest thing.

thoughts?

l.




More information about the Libre-soc-dev mailing list