```vfmaddrnd231pd是谁?```
Who is vfmaddrnd231pd?

原始链接: https://purplesyringa.moe/blog/who-is-vfmaddrnd231pd/

``` 指令 `vfmaddrnd231pd` 出现在英特尔2024年版的《软件开发手册》(SDM)中,但在2026年版中被完全移除,尽管它曾拥有专属的文档、表格和伪代码。该指令旨在为FMA操作提供每条指令级别的舍入控制,有可能在不依赖AVX-512的情况下实现更快的依赖舍入的算法。然而,它在实际中无法运行:GNU汇编器无法识别它,SDM中提到的内部函数在Clang和ICC中均不存在,其操作码包含一个含义不明、未文档化记录的前缀(`DDS`),该前缀在其他任何地方都未出现。最关键的是,当在支持FMA的Haswell CPU上手动汇编并执行该指令时,会引发#UD(未定义指令)异常。作者推测,英特尔可能在开发过程中最后一刻取消了该指令,但未能将其从文档中完全清除。 ```

Hacker News 的讨论帖探讨了神秘的 x86 指令 `vfmaddrnd231pd`。评论者指出,一份旧的 binutils 文档解释了 VEX.vvvv 编码以及 DDS/NDS 形式。该指令只出现在 Intel SDM 第 2 卷修订版 082–084 中,而没有出现在变更文档里,暗示它并非有意加入。它可能因硬件问题导致从未能正常工作而被移除;一位评论者说,当 Intel 重新在客户端 CPU 上承诺支持 AVX-512 时,它以 EVEX 形式回归。其他人讨论了这类令人费解的名称如何反映 x86 积累的历史包袱和糟糕的人类可读性。讨论逐渐转向汇编器语法是否应更易处理,尤其是在 AI 和 LLM 背景下,并提到 symbolasm 等项目。总体而言,一个小众的历史谜团演变成关于 x86 演进、文档错误和汇编语言设计的更广泛对话。
相关文章

原文

vfmaddrnd231pd is a unique instruction from the FMA instruction set. Most instructions in that set have mnemonics like vfmadd231pd, but here rnd means something very specific. The Intel Software Development Manual documents it as:

VFMADDRND231PD – Fused Multiply-Add of Packed Double-Precision Floating-Point Values with rounding control

[…] The immediate byte defines several bit fields that control rounding, DAZ, FTZ, and exception suppression (See Table 5-3).

Most x86 floating-point instructions use the global rounding mode and settings, changing which is pretty slow. But vfmaddrnd231pd allows the rounding mode to be controlled on a per-instruction basis, and since FMA can emulate addition, subtraction, and multiplication, this mechanism effectively allows any arithmetic to have controllable rounding without AVX-512 – making some algorithms that rely on rounding incredibly faster.

Or so it would, if this instruction actually existed. GNU assembler doesn’t recognize it. The Intel C/C++ Compiler intrinsics _mm_fmaddround_pd and _mm256_fmaddround_pd that SDM mentions are absent not only from Clang, but from ICC as well. Trying to assemble the instructions by hand from the SDM opcode list reveals another issue:

VEX.DDS.128.66.0F3A.W1 B8 /r /ib

VEX is the VEX prefix, but what is DDS? This opcode is the only mention of DDS in the SDM, and this SO answer says that DDS is merely used for documentation and was removed from later SDM versions, but the fact that it’s still present here is suspicious. And when you actually run the instruction on a CPU that supports the FMA instruction set, like my Haswell, it raises #UD (“UnDefined instruction”)!

I already found it strange that the SDM only lists vfmaddrnd231pd and not other variants like using pd/ps/sd/ss or 132/213/231, which other FMA instructions have, but this confirmed my suspicions. It was at that point that I downloaded a more recent version of the SDM and noticed that this instruction is absent in the 2026 edition of the SDM, despite being present in the 2024 version.

I must say I’m incredibly confused. This instruction doesn’t look like a typo in the documentation, since the docs contain unique tables and pseudocode that isn’t similar to any other instruction. My best hypothesis is that Intel wanted to add the vfmaddrnd* set, then found an issue with it at the last moment and removed it from the CPU, but didn’t quite adjust the SDM correctly. But I have no way to confirm that.

If anyone reading this has a friend at Intel, I’d love to know the answer.

联系我们 contact @ memedata.com