4 ms·
Populating x86-64 floating point registers is also an amusing subject. The obvious instruction for loading a (64-bit) float into an xmm register is movsd. With
by gsg 11y ago
Populating x86-64 floating point registers is also an amusing subject.
The obvious instruction for loading a (64-bit) float into an xmm register is movsd. With a memory source operand, the higher part of the register is zeroed, which is what you want. No problem.
Now the fun part: if the source is not memory but another xmm register, the higher part of the register is not zeroed. This induces a false dependency on the previous value of the destination register that can cause performance issues. To avoid this problem, such register-register copies should be done with a packed move instruction. (Or vmovsd, but that was added much later.)
The obvious packed move instruction for 64-bit floats is movapd, but we can do better than that by using movaps - it is still a float domain instruction but is a byte smaller.
So the optimal way to move a single double from one register to another is to use a vector move of the wrong type.