将旧的SSE编码指令和VEX编码的指令混合在同一代码路径中可以吗? [英] Is it okay to mix legacy SSE encoded instructions and VEX encoded ones in the same code path?

查看:78
本文介绍了将旧的SSE编码指令和VEX编码的指令混合在同一代码路径中可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着AVX的推出,英特尔将VEX编码方案引入了Intel 64和IA-32架构.此编码方案通常与AVX指令一起使用.我想知道是否可以混合使用VEX编码的指令和现在称为旧版SSE"的指令.

Along with the introduction of AVX, Intel introduced the VEX encoding scheme into the Intel 64 and IA-32 architecture. This encoding scheme is used mostly with AVX instructions. I was wondering if it's okay to intermix VEX-encoded instructions and the now called "legacy SSE" instructions.

我问这个问题的主要原因是代码大小.考虑以下两个说明:

The main reason for me asking this question is code size. Consider these two instructions :

shufps xmm0, xmm0, 0
vshufps xmm0, xmm0, xmm0, 0

我通常使用第一个将标量值广播"到XMM寄存器中的所有位置.现在,指令集说这两者(在这种情况下)的唯一区别是VEX编码的指令清除了YMM寄存器的高位(> = 128).假设我不需要,在这种情况下使用VEX编码的版本有什么优势?第一条指令占用4个字节(0FC6C000),第二条指令占用5个字节(C5F8C6C000).

I commonly use the first one to "broadcast" a scalar value to all the places in an XMM register. Now, the instruction set says that the only difference between these two (in this case) is that the VEX-encoded one clears the higher (>=128) bits of the YMM register. Supposing that I don't need that, what's the advantage of using the VEX-encoded version in this case? The first instruction takes 4 bytes (0FC6C000), the second - 5 (C5F8C6C000).

感谢所有答案.

推荐答案

在当前实现中,如果(至少)上半部分已重置(VZEROUPPER或VZEROALL),则使用旧版SSE指令不会受到任何惩罚.

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

如第128页中的 Agner Fog:使用旧版优化子程序中所述使用(某些)上半部分时的SSE指令会降低性能.当进入YMM寄存器在中间被分开的状态时,将产生这种惩罚,而当离开该状态时,将再次引起这种惩罚.

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.

混合使用VEX编码的128位指令和旧版SSE指令不是问题.

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

这篇关于将旧的SSE编码指令和VEX编码的指令混合在同一代码路径中可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆