简体   繁体   English

GCC无法对64位乘法进行矢量化。 可以在AVX2上对64位x 64位 - > 128位加宽乘法进行矢量化吗?

[英]GCC couldn't vectorize 64-bit multiplication. Can 64-bit x 64-bit -> 128-bit widening multiplication be vectorized on AVX2?

I try to vectorize a CBRNG which uses 64bit widening multiplication. 我尝试对使用64位加宽乘法的CBR​​NG进行矢量化。

static __inline__ uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t* hip) {
    __uint128_t product = ((__uint128_t)a)*((__uint128_t)b);
    *hip = product>>64;
    return (uint64_t)product;
}

Is such a multiplication exists in a vectorized form in AVX2? 这种乘法在AVX2中是否以矢量化形式存在?

No. There's no 64 x 64 -> 128 bit arithmetic as a vector instruction. 没有。作为矢量指令,没有64 x 64 - > 128位算术。 Nor is there a vector mulhi type instruction (high word result of multiply). 也没有矢量mulhi类型指令(乘法的高字结果)。

[V]PMULUDQ can do 32 x 32 -> 64 bit by only considering every second 32 bit unsigned element, or unsigned doubleword, as a source, and expanding each 64 bit result into two result elements combined as an unsigned quadword. [V] PMULUDQ只能将每秒32位无符号元素或无符号双字作为源,并将每个64位结果扩展为两个结果元素组合为无符号四字,从而可以执行32 x 32 - > 64位。

The best you can probably hope for right now is Haswell's MULX instruction, which has more flexible register use, and does not affect the flags register - eliminating some stalls. 您现在可能希望的最好的是Haswell的MULX指令,它具有更灵活的寄存器使用,并且不会影响标志寄存器 - 消除了一些停顿。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM