_addcarry_u64 and _addcarryx_u64 with MSVC and ICC

前端 未结 2 1783
無奈伤痛
無奈伤痛 2020-11-28 16:27

MSVC and ICC both support the intrinsics _addcarry_u64 and _addcarryx_u64.

According to Intel\'s Intrinsic Guide and white paper these shou

相关标签:
2条回答
  • 2020-11-28 17:00

    They map to adc, adcx AND adox. The compiler decides which instructions to use, based on how you use them. If you perform two big-int additions in parallel the compiler will use adcx and adox, for higher throughput. For example:

    unsigned char c1 = 0, c2 = 0
    for(i=0; i< 100; i++){ 
        c1 = _addcarry_u64(c1, res[i], a[i], &res[i]);
        c2 = _addcarry_u64(c2, res[i], b[i], &res[i]);
    }
    
    0 讨论(0)
  • 2020-11-28 17:06

    Related, GCC does not support ADOX and ADCX at the moment. "At the moment" includes GCC 6.4 (Fedora 25) and GCC 7.1 (Fedora 26). GCC effectively disabled the intrinsics, but it still advertises support by defining __ADX__ in the preprocessor. Also see Issue 67317, Silly code generation for _addcarry_u32/_addcarry_u64. Many thanks to Xi Ruoyao for finding the issue.

    According to Uros Bizjak on the GCC Help mailing list, GCC may never support the intrinsics. Also see GCC does not generate ADCX or ADOX for _addcarryx_u64.

    Clang has its own set of issues with respect to ADOX and ADCX. Clang 3.9 and 4.0 crash when attempting to use them. Also see Issue 34249, Panic when using _addcarryx_u64 with Clang 3.9. According to Craig Topper, it should be fixed in Clang 5.0.

    My apologies for posting the information under a MSVC question. This is one of the few hits when searching for information about using the intrinsics.

    0 讨论(0)
提交回复
热议问题