```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",引发了关于汇编语言可读性的争论。评论者 Lerc 认为,难以理解的指令名称反映了人们与底层计算直接接触的缺失,并指出更好的指令集表示方式可以减轻芯片设计者和编译器编写者的认知负担。他们推测,人工智能最终或许能够弥合被遗忘领域与现代问题之间的鸿沟,并提出了一个有趣的挑战:设计一种让复杂指令集变得易于理解使用的汇编器。 另一位评论者反驳说,汇编语法的主要作用是指令编码的映射,而非服务于人类的可读性——x86 那些奇怪的名称和立即数特性存在是为了与硬件保持一致,而非为了方便用户。ARM 也有类似的权衡取舍。 讨论随后转向更深层的担忧:如果汇编成为一门失传的艺术,谁来传达引导大语言模型连接这些思想所需的意图?一位用户链接到该指令的文档,推测它是因硬件缺陷而被移除的。其他人则指出,RISC-V 中同样荒谬的名称显然是从 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