How to use bits in a byte to set dwords in ymm register without AVX2? (Inverse of vmovmskps)

后端 未结 2 578
离开以前
离开以前 2020-12-11 10:59

What I\'m trying to achieve is based on each bit in a byte, set to all ones in each dword in a ymm register (or memory location)

e.g.

al = 0110 0001
         


        
2条回答
  •  旧时难觅i
    2020-12-11 11:29

    Preface: I know that this doesn't fulfill the (whole) requirements of the question, so this answer is not acceptable. I just post it for future reference.

    There is a new AVX512(VL|BW) instruction named VPMOVM2B which does what you want in exactly one instruction:

    VPMOVM2B ymm1, k1
    

    Sets each byte in YMM1 to all 1’s or all 0’s based on the value of the corresponding bit in k1.

    I couldn't test it, but it should be what you want.

提交回复
热议问题