Skip to content

shader: lower binary16 VOP1 reciprocal square root and exponent - #3557

Closed
lambirou wants to merge 1 commit into
R0Y00:mainfrom
lambirou:shader/f16-rsq-exp
Closed

lambirou wants to merge 1 commit into
R0Y00:mainfrom
lambirou:shader/f16-rsq-exp

Conversation

@lambirou

Copy link
Copy Markdown
Contributor

Part of the VOP1 f16 slice. Stacked on #3556; rebase after it lands.

This adds the plain binary16 VOP1 forms of v_rsq_f16 and v_exp_f16, e32 and e64 (four reference rows):

  • Widen the low half, evaluate rsqrt or exp2 in binary32, then narrow with the existing integer nearest-even conversion.
  • Apply the RDNA 2 special selects: rsq maps zero to source | 0x7c00, 0x7c00 to 0 and anything above 0x7c00 to 0x7e00; exp applies the 70 midpoint corrections, 0xce40 to 0 and magnitudes above 0x7c00 to 0x7e00.
  • f16_rsq_exp_result follows the P4a contract, and a Python midpoint table is checked against the C++ table in the direct compute lowering.

Tests

  • pixel_aot_f16_rsq_exp_hardware passed on the AMD RX 9060 XT, and pixel_aot_f16_rsq_exp_warp passed on WARP.
  • The WARP replay of the 195 pixel_aot_|compute_store_aot_ entries passes 195/195, 0 fail, 0 skip.
  • Coverage on that run: 1,550/1,968 gfx1013 and 1,541/1,863 gfx1030.
  • form_coverage_check.py passes; rdna2_tools_check.py reports 159 tests and 19 LLVM_LIB skips.

Limits

The high half of the destination is not observed. The rsqrt/exp2 error window is not reproduced bit for bit; exp midpoints are corrected and the fixture avoids ambiguous rsq sources. NaN/infinity constants, runtime sources, DPP/SDWA and the remaining log/sin/cos forms are out of scope.

The branch includes the commits of #3542 (and #3549/#3556 below it); they drop out of the diff once those land.

AI-assisted.

@lambirou

Copy link
Copy Markdown
Contributor Author

Merged as part of #3564: that PR was squashed onto main at f0a10b12, and the reciprocal-square-root/exponent lowerings are in main (the squash body lists this commit). Closing this now-redundant PR. The next DPP slice is #3578.

@lambirou lambirou closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant