shader: on RDNA2, VOP3 0x140 and VOP2 0x006 are v_fma_legacy_f32 and v_fmac_legacy_f32 (one rounding) #321

Closed
opened 2026-11-27 11:23:21 +00:00 by github-bot · 3 comments
Owner

@⁠gagarinyury on GitHub · 2026-11-27 11:21 UTC · original

The opcode table names VOP3 0x140 v_mad_legacy_f32 and VOP2 0x006 v_mac_legacy_f32, and the lowering multiplies with the legacy rule and then adds, rounding twice. That is GFX10.1. On GFX10.3 (RDNA2) these encodings are v_fma_legacy_f32 and v_fmac_legacy_f32, fused: llvm-mc -mcpu=gfx1030 assembles v_fma_legacy_f32 v0, v1, v2, v3 to the same bytes as gfx1010's v_mad_legacy_f32 and rejects v_mad_legacy_f32 as "not supported on this GPU"; gfx1010 and gfx1013 do the opposite (GFX10_3Insts implies FeatureFmaLegacy32Insts, and VOP2 0x006 is V_FMAC_LEGACY_F32 in the GFX10_B decoder namespace). The legacy zero rule (0 times anything is 0) stays; only the product's rounding changes, so results differ by at most one rounding step where the product is inexact. semantics_tests models both as mad_legacy.

Plan: rename both, lower them as a fused multiply-add with the legacy zero rule, and update the semantics model.

**@⁠gagarinyury** on GitHub · 2026-11-27 11:21 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321) The opcode table names VOP3 0x140 `v_mad_legacy_f32` and VOP2 0x006 `v_mac_legacy_f32`, and the lowering multiplies with the legacy rule and then adds, rounding twice. That is GFX10.1. On GFX10.3 (RDNA2) these encodings are `v_fma_legacy_f32` and `v_fmac_legacy_f32`, fused: `llvm-mc -mcpu=gfx1030` assembles `v_fma_legacy_f32 v0, v1, v2, v3` to the same bytes as gfx1010's `v_mad_legacy_f32` and rejects `v_mad_legacy_f32` as "not supported on this GPU"; gfx1010 and gfx1013 do the opposite (`GFX10_3Insts` implies `FeatureFmaLegacy32Insts`, and VOP2 0x006 is `V_FMAC_LEGACY_F32` in the GFX10_B decoder namespace). The legacy zero rule (0 times anything is 0) stays; only the product's rounding changes, so results differ by at most one rounding step where the product is inexact. `semantics_tests` models both as `mad_legacy`. Plan: rename both, lower them as a fused multiply-add with the legacy zero rule, and update the semantics model.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 11:23:21 +00:00
Author
Owner

@⁠gagarinyury on GitHub · 2026-11-27 11:22 UTC · original

/claim

**@⁠gagarinyury** on GitHub · 2026-11-27 11:22 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321#issuecomment-7216994377) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 11:22 UTC · original

Claimed by @⁠gagarinyury. Open a draft pull request with Refs #321 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-27 11:22 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321#issuecomment-7216997768) Claimed by @⁠gagarinyury. Open a draft pull request with `Refs #321` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-28 00:36 UTC · original

Thank you for this. It is fixed on main by #323. I have not checked every case from this report in the game myself, so please retest on main a6a58361 and reopen this if you still see it. Closing as fixed.

**@⁠LakshanSivakumar** on GitHub · 2026-11-28 00:36 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321#issuecomment-7231043946) Thank you for this. It is fixed on main by #323. I have not checked every case from this report in the game myself, so please retest on main a6a58361 and reopen this if you still see it. Closing as fixed.
This discussion has been locked. Commenting is limited to contributors.
No description provided.