How can I set the lowest 64 bits of a YMM register to some constant, in the least number of clock cycles? I know various ways that I can do this using SSE instructions, as well as the AVX instruction VBROADCASTSD, but I’m not sure which method will yield the best result.
Edit: I still need to use the complete YMM register after setting the 64-bit part.
Thanks for your help!
If you only need to set lowest 64 bits and other YMM bits do not matter, use
VMOVQ.If you need to preserve other bits in YMM register, the most efficient way is to use
VBLENDPD. Alternatively, you can clear the lowest 64 bits withVANDPD, then load the constant withVORPD.AVX2 allows other alternatives to do it:
VPMASKMOVDorVPBLENDD(but it is not yet supported by any processor).