Repository navigation
shader, docs: keep GFX10.1 legacy MAD/MAC names - #71
Merged
Merged
Conversation
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
Contributor
Author
simnJS
approved these changes
Nov 25, 2026
simnJS
left a comment
Collaborator
There was a problem hiding this comment.
Checked against LLVM 19.1.7: MAD/MAC need HasMadMacF32Insts and legacy FMA/FMAC need HasFmaLegacy32, so keeping both name sets fits this console's mix. Decoding and lowering are unchanged, and the new VALU cases tell fused results from unfused ones and IEEE zeros from legacy ones; I checked the maths. Nit for later: the decode test repeats corpus entries 2097, 2099 and 2105. CI is green, so I'm merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Resolves the legacy MAD/MAC question of #64 (the decoder gaps were filled by #68). XTP keeps
v_mad_legacy_f32at VOP30x140andv_mac_legacy_f32at VOP20x006(and its e64 form): unfused, with the legacy rule 0 × x = +0.Evidence:
V_MAD_LEGACY_F32(0x140) andV_MAD_F32(0x141) sit under the same predicate,HasMadMacF32Insts, andV_MAC_F32is gated on it too.V_FMA_LEGACY_F32andV_FMAC_LEGACY_F32needHasFmaLegacy32(GFX10.3 instructions) and are decoded only in theGFX10_Bnamespace (VOP3Instructions.td, VOP2Instructions.td).FeatureMadMacF32Instsand gfx1030 does not. gfx1013 is GFX10.1 plusFeatureGFX10_AEncoding("Has BVH ray tracing instructions"), and it is the only target with both.v_mad_f32orv_mac_f32at all.v_mad_f32(VOP30x141)v_mac_f32v_madak_f32image_bvh_intersect_rayimage_bvh64_intersect_ray0x1400x006v_dot*This matches the GFX10.1 + BVH profile that LLVM calls gfx1013, which decodes
0x140and0x006with the legacy MAD/MAC names. The conformance test now documents the two names as intended differences from the GFX10.3 corpus, and it still flags them if they go stale. The existing lowering was already unfused and already applied the zero rule. The new tests pin that behaviour.Fixes: #64
Depends on: none
Area
Shader decoder conformance and VALU tests, plus shader analysis documentation.
Tests
cargo xtask pr-checkpasses on my machine with--skip testNew or changed behaviour has tests that need no game files, or I explain below why it cannot
Ran on a title: no
cargo test -p xtp-shader --libreported 492 passed, 0 failed, and 41 ignored.legacy_mad_mac_round_product_and_preserve_zero_rulerunsv_mad_legacy_f32and bothv_mac_legacy_f32forms throughrun_cases, so it fails rather than skips without a device. With a = b = 1 + 2⁻¹² and c = -(1 + 2⁻¹¹), the unfused result is +0, while a fused one would be 2⁻²⁴. It also checks 0 × ∞ + 1 = 1, NaN × 0 + 1 = 1 and 0 × -5 + (-0) = +0. It passed on an NVIDIA RTX 5070 and on WARP.cargo test -p xtp-shader --test gfx10_conformancepassed both tests. The new test checks MAD and both MAC forms.Provenance
The opcode and target-feature facts come from LLVM Project
llvmorg-19.1.7(Apache-2.0 WITH LLVM-exception). No LLVM implementation code was copied.The decoder test reuses three encodings from the checked-in LLVM MC corpus, which includes
LICENSE-LLVM.txt. LLVM Projectllvmorg-19.1.7AI assistance: AI coding tools wrote this change and its tests, mainly OpenAI Codex.
Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above