AVX512 - Add two 512-bit integers using _addcarryx_u64 function
Probably not what you're expecting, but it's possible to do a 512-bit add directly with AVX512 registers. The _addcarryx_u64() intrinsic is not necessary nor do you need to break up the register into scalars.

Taken from my blog: http://www.numberworld.org/y-cruncher/internals/addition.html#ks_add

The following is a little-endian 512-bit full-adder:

__m512i add512(uint32_t&amp; carry, __m512i A, __m512i B){

    const __m512i MAX_WORD = _mm512_set1_epi64(0xffffffffffffffff);

    __m512i s = _mm512_add_epi64(A, B);
    __mmask16 c = _mm512_cmplt_epu64_mask(s, A);
    __mmask16 m = _mm512_cmpeq_epi64_mask(s, MAX_WORD);

    {

        uint32_t c0 = _mm512_mask2int(c);
        uint32_t m0 = _mm512_mask2int(m);
        carry += m0;
        carry = (carry + c0*2); //  lea
        m0 ^= carry;
        carry &gt;&gt;= 8;
        m = _mm512_int2mask(m0);

    }

    return _mm512_mask_sub_epi64(s, m, s, MAX_WORD);
}


The carry parameter indicates the carry-in. It will be replaced with the carry-out. It must be either 0 or 1.



To clarify, this is little-endian across all 512 bits. So carry propagation goes from lowest address to highest address. I'm not sure if this is what you really wanted since your example seems to do it in big-endian with 64-bit granularity.

If you really do want this in big-endian, you will need to shuffle all the inputs and outputs since there's no way to efficiently reverse the direction of the carry-propagation.



Background:

This is something I attacked back in January of 2017 while I was experimenting with parallel adder algorithms. And somewhat by chance I managed to derive the general approach to the above method.

I've since been told that this sequence was already known internally to Intel, but they never published it. And it seems quite likely that the kadd mask instructions were specifically designed for parallel-prefix algorithms like the adder given here.