Is it okay to mix legacy SSE encoded instructions and VEX encoded ones in the same code path?

北城以北 提交于 2019-12-05 02:31:10

On current implementations, if (at least) the upper halves have been reset (VZEROUPPER or VZEROALL) there is no penalty for using legacy SSE instructions.

As detailed on page 128 in Agner Fog: optimizing subroutines in assembly, using legacy SSE instructions while (some) upper halves are in use carries a performance penalty. This penalty is incurred once when entering the state where YMM registers are split in the middle, and once again when leaving that state.

Mixing VEX-encoded 128-bit instructions and legacy SSE instructions is not a problem.

It's not safe. According to intel's software developer manual, VEX.128 version zeros the upper half of the YMM register, legacy SSE version doesn't. Worst thing: some assemblers (like gasm) may convert SHUFPS into VSHUFPS while creating object file (when -mavx flag is applied). I found exact same problem working with an assembly file.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!