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:21:55 +00:00 by gagarinyury · 3 comments
gagarinyury commented 2026-11-27 11:21:55 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T11:21:55Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6645428316 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T11:21:55Z. --- 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 commented 2026-11-27 11:22:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T11:22:14Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216994377 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321#issuecomment-7216994377). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T11:22:14Z. --- /claim
github-actions[bot] commented 2026-11-27 11:22:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T11:22:25Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216997768 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321#issuecomment-7216997768). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T11:22:25Z. --- Claimed by @gagarinyury. Open a draft pull request with `Refs #321` in its description within 24 hours, or the claim expires.
LakshanSivakumar commented 2026-11-28 00:36:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-28T00:36:15Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231043946 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/321#issuecomment-7231043946). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T00:36:15Z. --- 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#321
No description provided.