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

lkcl luke.leighton at gmail.com
Wed Apr 13 21:17:41 BST 2022

i found this which looks clear, well commented:

the nice thing is, each calculation with a tight for-loop is a blindingly-obvious candidate for a single SVP64 instruction.  even this:

        for (int i = 0; i < n; ++i) {
            std::uint64_t product = static_cast<std::uint32_t>(qhat) 
                            * static_cast<std::uint64_t>(divisor.digits_[i]);

but that would be modified to a vector of products (a single sv.mul) and a second loop would perform the add-with-carry

even this i believe is just sv.adde

            widedigit = 0;
            for (int i = 0; i < n; ++i) {
                widedigit += static_cast<std::uint64_t>(dividend.digits_[k + i])
                           + divisor.digits_[i];
                dividend.digits_[k + i] = widedigit;
                widedigit >>= 32;

from what i can gather, the number of instructions we end up with would be astoundingly, ridiculously low.


More information about the Libre-soc-dev mailing list