fix(shader): read v_ldexp_f16 src1 float inline constants as f16 #1966

Merged
Deftera186 merged 1 commit from upstream-pr/1966 into main 2026-10-10 06:06:16 +00:00
Deftera186 commented 2026-10-09 03:07:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Deftera186 on 2026-10-09T03:07:44Z.


What

v_ldexp_f16 read src1 with readU32, so a float inline constant in src1 gave the low 16 bits of its f32 pattern. For 0.5, 1.0, 2.0, 4.0 and their negatives that is 0, and the instruction returned src0 unchanged; for 1/(2*pi) (0x3e22f983) it is 0xf983 (-1661, clamped to -64), and the instruction returned a zero with the sign of src0. The hardware treats src1 as an f16 operand, so these constants arrive in their f16 encoding: 0.5 is 0x3800, an exponent of 14336. Measured on gfx1101, ldexp(1.0, 0.5) is +inf and ldexp(1.0, -0.5) is +0.

VOP3 src1 is now read through readF16SourceBits, which maps the nine float inline constants to their f16 bits and reads every other operand as before. Registers, integer inline constants and literals already matched the hardware, which uses their sign-extended low 16 bits (table below). SDWA is the only other form that can put an inline constant in src1; it keeps the old read bit for bit, since gfx11 has no SDWA to measure it on. VOP3 op_sel and src1 abs/neg on v_ldexp_f16 are still refused by the decoder.

Sources:

  • LLVM VOP2Instructions.td at 928f895, L1083-L1093: "The ldexp.f16 intrinsic expects a integer src1 operand, though the hardware encoding treats src1 as an f16"; LDEXP_F16_VOPProfile is VOPProfile <[f16, f16, f16, untyped]>. V_LDEXP_F16 uses it on subtargets with 16-bit instructions and without true16 (L1107-L1108), and gfx10 encodes it as VOP2 0x03b (L2384). llvm-mc 23.1.2 for gfx1013 accordingly encodes v_ldexp_f16_e64 v25, v4, 0x3800 with the inline constant 0.5 and 0x3118 with 1/(2*pi), while v_add_nc_u16 v25, v4, 0x3800 keeps a literal.
  • Hardware measurements on gfx1101 with the hardware oracle, below.

Tested

Gentoo Linux, RX 7700 XT (gfx1101), RADV (Mesa 26.2.3).

  • New execution test LdexpF16InlineConstants.cpp (ctest agc_driver_ldexp_f16_inline_constants): 32 f16 inputs (normal, subnormal, +0, -0) by 16 VOP3 src1 forms: the nine float inline constants, the integer inline constants 2, -1, 64 and -16, the literal 0x3f000000, an SGPR holding 0x3f000000 and a VGPR holding 0x3800. The expected values are the gfx1101 results in the mode the test compiles with (FLOAT_MODE 0xc0, IEEE=0, DX10_CLAMP=1).
  • Before the fix the test fails with ldexp f16 inline constants: v_ldexp_f16 0x3c00, 0.5 is 0x3c00, expected 0x7c00; 270 of the 512 results differ, all in the nine float-constant columns. After the fix it passes.
  • Full suite: 100% tests passed, 0 tests failed out of 495.
  • lavapipe: agc_driver_ldexp_f16_inline_constants, agc_driver_sdwa_ldexp_f16 and agc_driver_float16_misc pass on llvmpipe (LLVM 20.1.2, Mesa 25.2.8) in an Ubuntu 24.04 container with the packages and configure flags of the Linux CI job.

Hardware results on gfx1101 (oracle kernels assembled with -mattr=-real-true16, so the 16-bit operands are gfx10-style VGPRs), FLOAT_MODE 0xc0, IEEE=0, DX10_CLAMP=1. The recompiler result before the fix is in parentheses where it differed; after the fix every result matches.

src1 src1 bits before after src0 0x3c00 src0 0xbc00 src0 0x0001 src0 0x8000
0.5 0x0000 0x3800 0x7c00 (0x3c00) 0xfc00 (0xbc00) 0x7c00 (0x0001) 0x8000
-0.5 0x0000 0xb800 0x0000 (0x3c00) 0x8000 (0xbc00) 0x0000 (0x0001) 0x8000
1.0 0x0000 0x3c00 0x7c00 (0x3c00) 0xfc00 (0xbc00) 0x7c00 (0x0001) 0x8000
-1.0 0x0000 0xbc00 0x0000 (0x3c00) 0x8000 (0xbc00) 0x0000 (0x0001) 0x8000
2.0 0x0000 0x4000 0x7c00 (0x3c00) 0xfc00 (0xbc00) 0x7c00 (0x0001) 0x8000
-2.0 0x0000 0xc000 0x0000 (0x3c00) 0x8000 (0xbc00) 0x0000 (0x0001) 0x8000
4.0 0x0000 0x4400 0x7c00 (0x3c00) 0xfc00 (0xbc00) 0x7c00 (0x0001) 0x8000
-4.0 0x0000 0xc400 0x0000 (0x3c00) 0x8000 (0xbc00) 0x0000 (0x0001) 0x8000
1/(2*pi) 0xf983 0x3118 0x7c00 (0x0000) 0xfc00 (0x8000) 0x7c00 (0x0000) 0x8000
2 0x0002 0x0002 0x4400 0xc400 0x0004 0x8000
-1 0xffff 0xffff 0x3800 0xb800 0x0000 0x8000
64 0x0040 0x0040 0x7c00 0xfc00 0x7c00 0x8000
-16 0xfff0 0xfff0 0x0100 0x8100 0x0000 0x8000
literal 0x3f000000 0x0000 0x0000 0x3c00 0xbc00 0x0001 0x8000
SGPR holding 0x3f000000 0x0000 0x0000 0x3c00 0xbc00 0x0001 0x8000
VGPR holding 0x3800 0x3800 0x3800 0x7c00 0xfc00 0x7c00 0x8000

All 512 results of the test were measured in the 16 combinations of IEEE 0/1, f32 denormals flushed/kept, f16 denormals flushed/kept and DX10_CLAMP 0/1. The eight modes that keep f16 denormals give identical results. The eight that flush them differ in 142 results, all from the flush: a subnormal src0 reads as a signed zero (0x0001 with 0.5 gives 0x0000) and a result that is tiny before rounding is written as a signed zero (0x07ff with -1 gives 0x0000, not 0x0400). For normal src0 the float constants give the same results in all 16 modes. v_ldexp_f16 does not read the f16 denormal mode before or after this change.

A VOP3 literal src1, hand-encoded with .long to set every bit of the literal dword, reads as its sign-extended low 16 bits on gfx1101 in all 16 modes. With src0 1.0, the literals 0x00000002, 0x12340002 and 0xffff0002 give 0x4400, 0x0000fffe gives 0x3400, 0x00010000, 0x7fff0000 and 0x3f000000 give 0x3c00, 0x00008000 and 0x0000ffc0 give 0x0000, and 0x00003800, 0x00007fff and 0x0000003f give 0x7c00. The recompiler reads literals the same way before and after this change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4795445323 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966). Originally posted by [Deftera186](https://github.com/Deftera186) on 2026-10-09T03:07:44Z. --- ### What `v_ldexp_f16` read src1 with `readU32`, so a float inline constant in src1 gave the low 16 bits of its f32 pattern. For 0.5, 1.0, 2.0, 4.0 and their negatives that is 0, and the instruction returned src0 unchanged; for 1/(2*pi) (0x3e22f983) it is 0xf983 (-1661, clamped to -64), and the instruction returned a zero with the sign of src0. The hardware treats src1 as an f16 operand, so these constants arrive in their f16 encoding: 0.5 is 0x3800, an exponent of 14336. Measured on gfx1101, `ldexp(1.0, 0.5)` is +inf and `ldexp(1.0, -0.5)` is +0. VOP3 src1 is now read through `readF16SourceBits`, which maps the nine float inline constants to their f16 bits and reads every other operand as before. Registers, integer inline constants and literals already matched the hardware, which uses their sign-extended low 16 bits (table below). SDWA is the only other form that can put an inline constant in src1; it keeps the old read bit for bit, since gfx11 has no SDWA to measure it on. VOP3 `op_sel` and src1 `abs`/`neg` on `v_ldexp_f16` are still refused by the decoder. Sources: - LLVM `VOP2Instructions.td` at 928f895, [L1083-L1093](https://github.com/llvm/llvm-project/blob/928f895bc09ed7a1f7c2af25df1a538ddbb91729/llvm/lib/Target/AMDGPU/VOP2Instructions.td#L1083-L1093): "The ldexp.f16 intrinsic expects a integer src1 operand, though the hardware encoding treats src1 as an f16"; `LDEXP_F16_VOPProfile` is `VOPProfile <[f16, f16, f16, untyped]>`. `V_LDEXP_F16` uses it on subtargets with 16-bit instructions and without true16 ([L1107-L1108](https://github.com/llvm/llvm-project/blob/928f895bc09ed7a1f7c2af25df1a538ddbb91729/llvm/lib/Target/AMDGPU/VOP2Instructions.td#L1107-L1108)), and gfx10 encodes it as VOP2 0x03b ([L2384](https://github.com/llvm/llvm-project/blob/928f895bc09ed7a1f7c2af25df1a538ddbb91729/llvm/lib/Target/AMDGPU/VOP2Instructions.td#L2384)). llvm-mc 23.1.2 for gfx1013 accordingly encodes `v_ldexp_f16_e64 v25, v4, 0x3800` with the inline constant 0.5 and `0x3118` with 1/(2*pi), while `v_add_nc_u16 v25, v4, 0x3800` keeps a literal. - Hardware measurements on gfx1101 with the hardware oracle, below. ### Tested Gentoo Linux, RX 7700 XT (gfx1101), RADV (Mesa 26.2.3). - New execution test `LdexpF16InlineConstants.cpp` (ctest `agc_driver_ldexp_f16_inline_constants`): 32 f16 inputs (normal, subnormal, +0, -0) by 16 VOP3 src1 forms: the nine float inline constants, the integer inline constants 2, -1, 64 and -16, the literal 0x3f000000, an SGPR holding 0x3f000000 and a VGPR holding 0x3800. The expected values are the gfx1101 results in the mode the test compiles with (FLOAT_MODE 0xc0, IEEE=0, DX10_CLAMP=1). - Before the fix the test fails with `ldexp f16 inline constants: v_ldexp_f16 0x3c00, 0.5 is 0x3c00, expected 0x7c00`; 270 of the 512 results differ, all in the nine float-constant columns. After the fix it passes. - Full suite: `100% tests passed, 0 tests failed out of 495`. - lavapipe: `agc_driver_ldexp_f16_inline_constants`, `agc_driver_sdwa_ldexp_f16` and `agc_driver_float16_misc` pass on llvmpipe (LLVM 20.1.2, Mesa 25.2.8) in an Ubuntu 24.04 container with the packages and configure flags of the Linux CI job. Hardware results on gfx1101 (oracle kernels assembled with `-mattr=-real-true16`, so the 16-bit operands are gfx10-style VGPRs), FLOAT_MODE 0xc0, IEEE=0, DX10_CLAMP=1. The recompiler result before the fix is in parentheses where it differed; after the fix every result matches. | src1 | src1 bits before | after | src0 0x3c00 | src0 0xbc00 | src0 0x0001 | src0 0x8000 | |---|---|---|---|---|---|---| | 0.5 | 0x0000 | 0x3800 | 0x7c00 (0x3c00) | 0xfc00 (0xbc00) | 0x7c00 (0x0001) | 0x8000 | | -0.5 | 0x0000 | 0xb800 | 0x0000 (0x3c00) | 0x8000 (0xbc00) | 0x0000 (0x0001) | 0x8000 | | 1.0 | 0x0000 | 0x3c00 | 0x7c00 (0x3c00) | 0xfc00 (0xbc00) | 0x7c00 (0x0001) | 0x8000 | | -1.0 | 0x0000 | 0xbc00 | 0x0000 (0x3c00) | 0x8000 (0xbc00) | 0x0000 (0x0001) | 0x8000 | | 2.0 | 0x0000 | 0x4000 | 0x7c00 (0x3c00) | 0xfc00 (0xbc00) | 0x7c00 (0x0001) | 0x8000 | | -2.0 | 0x0000 | 0xc000 | 0x0000 (0x3c00) | 0x8000 (0xbc00) | 0x0000 (0x0001) | 0x8000 | | 4.0 | 0x0000 | 0x4400 | 0x7c00 (0x3c00) | 0xfc00 (0xbc00) | 0x7c00 (0x0001) | 0x8000 | | -4.0 | 0x0000 | 0xc400 | 0x0000 (0x3c00) | 0x8000 (0xbc00) | 0x0000 (0x0001) | 0x8000 | | 1/(2*pi) | 0xf983 | 0x3118 | 0x7c00 (0x0000) | 0xfc00 (0x8000) | 0x7c00 (0x0000) | 0x8000 | | 2 | 0x0002 | 0x0002 | 0x4400 | 0xc400 | 0x0004 | 0x8000 | | -1 | 0xffff | 0xffff | 0x3800 | 0xb800 | 0x0000 | 0x8000 | | 64 | 0x0040 | 0x0040 | 0x7c00 | 0xfc00 | 0x7c00 | 0x8000 | | -16 | 0xfff0 | 0xfff0 | 0x0100 | 0x8100 | 0x0000 | 0x8000 | | literal 0x3f000000 | 0x0000 | 0x0000 | 0x3c00 | 0xbc00 | 0x0001 | 0x8000 | | SGPR holding 0x3f000000 | 0x0000 | 0x0000 | 0x3c00 | 0xbc00 | 0x0001 | 0x8000 | | VGPR holding 0x3800 | 0x3800 | 0x3800 | 0x7c00 | 0xfc00 | 0x7c00 | 0x8000 | All 512 results of the test were measured in the 16 combinations of IEEE 0/1, f32 denormals flushed/kept, f16 denormals flushed/kept and DX10_CLAMP 0/1. The eight modes that keep f16 denormals give identical results. The eight that flush them differ in 142 results, all from the flush: a subnormal src0 reads as a signed zero (0x0001 with 0.5 gives 0x0000) and a result that is tiny before rounding is written as a signed zero (0x07ff with -1 gives 0x0000, not 0x0400). For normal src0 the float constants give the same results in all 16 modes. `v_ldexp_f16` does not read the f16 denormal mode before or after this change. A VOP3 literal src1, hand-encoded with `.long` to set every bit of the literal dword, reads as its sign-extended low 16 bits on gfx1101 in all 16 modes. With src0 1.0, the literals 0x00000002, 0x12340002 and 0xffff0002 give 0x4400, 0x0000fffe gives 0x3400, 0x00010000, 0x7fff0000 and 0x3f000000 give 0x3c00, 0x00008000 and 0x0000ffc0 give 0x0000, and 0x00003800, 0x00007fff and 0x0000003f give 0x7c00. The recompiler reads literals the same way before and after this change. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
MarcZX10 commented 2026-10-09 03:14:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:14:29Z.


I verified the Actions API for this exact head: Build, Conventions and Progress report are marked action_required, so upstream CI has not run yet. Per CONTRIBUTING, a maintainer needs to approve those workflow runs; please request that approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073510441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#issuecomment-6073510441). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T03:14:29Z. --- I verified the Actions API for this exact head: Build, Conventions and Progress report are marked `action_required`, so upstream CI has not run yet. Per CONTRIBUTING, a maintainer needs to approve those workflow runs; please request that approval.
MarcZX10 commented 2026-10-09 03:14:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:14:43Z.

Review: COMMENTED


Reviewed the complete diff. The change is scoped to VOP3 src1, which can encode the scalar float-inline constants; VOP2 src1 is a VGPR field and remains unchanged, as does SDWA. readF16SourceBits maps the supported inline-float encodings and leaves literals/register sources on their existing raw-bit path. The new execution test is picked up by the existing tests/execution/*.cpp glob and covers inline floats, integer inline values, literals and register sources across normal/subnormal/zero inputs. The reported hardware and lavapipe results are detailed. I found no code issue; I am holding approval until the action_required upstream checks run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5465312393 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#pullrequestreview-5465312393). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T03:14:43Z. **Review:** COMMENTED --- Reviewed the complete diff. The change is scoped to VOP3 src1, which can encode the scalar float-inline constants; VOP2 src1 is a VGPR field and remains unchanged, as does SDWA. `readF16SourceBits` maps the supported inline-float encodings and leaves literals/register sources on their existing raw-bit path. The new execution test is picked up by the existing `tests/execution/*.cpp` glob and covers inline floats, integer inline values, literals and register sources across normal/subnormal/zero inputs. The reported hardware and lavapipe results are detailed. I found no code issue; I am holding approval until the `action_required` upstream checks run.
snoozedDev commented 2026-10-09 03:51:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by snoozedDev on 2026-10-09T03:51:12Z.


Re-measured on RDNA2: Ryzen 7 7700X iGPU (Raphael, gfx1036, not the PS5's gfx1013), tools/hw-oracle on Linux (hsa-rocr 7.2.4, LLVM 22.1.8), head 7ba98071. LdexpCode words 7-39 unchanged (with s8 = 0x3f000000, v5 = 0x3800 set first), gfx10-style 16-bit operands so no -mattr, wave32, in the same 16 modes as above.

  • All 512 cells match Rows bit for bit in the 8 modes keeping f16 denormals, including the test's mode; the 8 flushing modes differ in 142 cells, the same count as on gfx1101.
  • The 12 hand-encoded VOP3 literals give exactly the values in the description, in all 16 modes for normal src0: a literal reads as its sign-extended low 16 bits here too.
  • Hosts: agc_driver_ldexp_f16_inline_constants passes on an RTX 3090 (NVIDIA 610.57.04) and on the RADV iGPU (Mesa 26.2.2); with main's FloatInstructions.cpp both fail at v_ldexp_f16 0x3c00, 0.5 is 0x3c00, expected 0x7c00.

Bodies, rows and per-mode results: https://gist.github.com/snoozedDev/c81c82507b46f9de87c5ecbdff54cde6 (pr1966-*). Generated with Claude Code (Claude Fable 5.1), driven and checked by me; the numbers are the hardware's output.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073896950 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#issuecomment-6073896950). Originally posted by [snoozedDev](https://github.com/snoozedDev) on 2026-10-09T03:51:12Z. --- Re-measured on RDNA2: Ryzen 7 7700X iGPU (Raphael, **gfx1036**, not the PS5's gfx1013), `tools/hw-oracle` on Linux (hsa-rocr 7.2.4, LLVM 22.1.8), head 7ba98071. `LdexpCode` words 7-39 unchanged (with `s8 = 0x3f000000`, `v5 = 0x3800` set first), gfx10-style 16-bit operands so no `-mattr`, wave32, in the same 16 modes as above. - All 512 cells match `Rows` bit for bit in the 8 modes keeping f16 denormals, including the test's mode; the 8 flushing modes differ in 142 cells, the same count as on gfx1101. - The 12 hand-encoded VOP3 literals give exactly the values in the description, in all 16 modes for normal src0: a literal reads as its sign-extended low 16 bits here too. - Hosts: `agc_driver_ldexp_f16_inline_constants` passes on an RTX 3090 (NVIDIA 610.57.04) and on the RADV iGPU (Mesa 26.2.2); with `main`'s `FloatInstructions.cpp` both fail at `v_ldexp_f16 0x3c00, 0.5 is 0x3c00, expected 0x7c00`. Bodies, rows and per-mode results: https://gist.github.com/snoozedDev/c81c82507b46f9de87c5ecbdff54cde6 (`pr1966-*`). Generated with Claude Code (Claude Fable 5.1), driven and checked by me; the numbers are the hardware's output.
CouchRiv commented 2026-10-09 05:54:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T05:54:23Z.


The SDWA form can be measured on RDNA2, which has SDWA. On gfx1036 (Radeon 610M) with tools/hw-oracle, wave32, IEEE=0, DX10_CLAMP=1, f16 denormals kept, v_ldexp_f16_sdwa vN, v4, <src1> src0_sel:WORD_0 dst_sel:DWORD, src0 = 1.0 (0x3c00):

src1 src1_sel:WORD_0 src1_sel:WORD_1 this PR / main (WORD_0, WORD_1)
0.5 0x7c00 0x3c00 0x3c00, 0x7c00
-0.5 0x0000 0x3c00
1.0 0x7c00 0x3c00 0x3c00, 0x7c00
-4.0 0x0000 0x3c00
1/(2*pi) (hand-encoded, llvm-mc refuses it) 0x7c00 0x3c00 0x0000, 0x7c00
-16 (integer) 0x0100 0x3800 same as hardware
SGPR 0x3f000000 0x3c00 same as hardware

So SDWA also reads a float inline constant as its f16 bits, zero-extended to 32 bits (WORD_1 is 0). Integer constants are sign-extended (WORD_1 of -16 is 0xffff). The SDWA path still reads the f32 bits and differs on these rows. The same holds for src0 0xbc00, 0x0001, 0x07ff and 0x3555, and with f16 denormals flushed apart from the flush itself. The VOP3 0.5 and 1/(2*pi) rows I ran as controls match your table.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6075201496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#issuecomment-6075201496). Originally posted by [CouchRiv](https://github.com/CouchRiv) on 2026-10-09T05:54:23Z. --- The SDWA form can be measured on RDNA2, which has SDWA. On gfx1036 (Radeon 610M) with `tools/hw-oracle`, wave32, IEEE=0, DX10_CLAMP=1, f16 denormals kept, `v_ldexp_f16_sdwa vN, v4, <src1> src0_sel:WORD_0 dst_sel:DWORD`, src0 = 1.0 (0x3c00): | src1 | src1_sel:WORD_0 | src1_sel:WORD_1 | this PR / `main` (WORD_0, WORD_1) | |---|---|---|---| | 0.5 | 0x7c00 | 0x3c00 | 0x3c00, 0x7c00 | | -0.5 | 0x0000 | | 0x3c00 | | 1.0 | 0x7c00 | 0x3c00 | 0x3c00, 0x7c00 | | -4.0 | 0x0000 | | 0x3c00 | | 1/(2*pi) (hand-encoded, llvm-mc refuses it) | 0x7c00 | 0x3c00 | 0x0000, 0x7c00 | | -16 (integer) | 0x0100 | 0x3800 | same as hardware | | SGPR 0x3f000000 | 0x3c00 | | same as hardware | So SDWA also reads a float inline constant as its f16 bits, zero-extended to 32 bits (WORD_1 is 0). Integer constants are sign-extended (WORD_1 of -16 is 0xffff). The SDWA path still reads the f32 bits and differs on these rows. The same holds for src0 0xbc00, 0x0001, 0x07ff and 0x3555, and with f16 denormals flushed apart from the flush itself. The VOP3 0.5 and 1/(2*pi) rows I ran as controls match your table.
johnmaia commented 2026-10-09 08:59:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T08:59:49Z.


NVIDIA and Intel results on Windows, to go with the RADV runs.

Windows 11, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, full ctest with ANYPS5_REQUIRE_VULKAN=1 on both GPUs of one machine: RTX 4080 (driver 617.42) and Intel UHD Graphics 770 (Raptor Lake-S, driver 101.6129, Vulkan 1.3.295), selected with ANYPS5_GPU. Base: main 6cc0503d plus #2093, since main alone does not build its tests right now (spirv/unified1/spirv.hpp not found).

RTX 4080 UHD 770
base 494/494 489/494
base + this PR 495/495 490/495

agc_driver_ldexp_f16_inline_constants passes on both GPUs. The five UHD 770 failures are the same tests with and without this PR (vop3_mad_i64, #1246, plus four filed as #2114), so nothing new fails.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077780447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#issuecomment-6077780447). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-09T08:59:49Z. --- NVIDIA and Intel results on Windows, to go with the RADV runs. Windows 11, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, full `ctest` with `ANYPS5_REQUIRE_VULKAN=1` on both GPUs of one machine: RTX 4080 (driver 617.42) and Intel UHD Graphics 770 (Raptor Lake-S, driver 101.6129, Vulkan 1.3.295), selected with `ANYPS5_GPU`. Base: `main` `6cc0503d` plus #2093, since `main` alone does not build its tests right now (`spirv/unified1/spirv.hpp` not found). | | RTX 4080 | UHD 770 | |---|---|---| | base | 494/494 | 489/494 | | base + this PR | 495/495 | 490/495 | `agc_driver_ldexp_f16_inline_constants` passes on both GPUs. The five UHD 770 failures are the same tests with and without this PR (`vop3_mad_i64`, #1246, plus four filed as #2114), so nothing new fails.
popcoder565 commented 2026-10-09 09:26:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T09:26:09Z.


NVIDIA data point. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), GCC 15.2.0 (WinLibs r7), Release. Head 7ba98071 merged onto main d9484c71, together with #1979 and #1963.

agc_driver_ldexp_f16_inline_constants, agc_driver_sdwa_ldexp_f16 and agc_driver_float16_misc pass.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078180072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#issuecomment-6078180072). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T09:26:09Z. --- NVIDIA data point. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), GCC 15.2.0 (WinLibs r7), Release. Head `7ba98071` merged onto `main` d9484c71, together with #1979 and #1963. `agc_driver_ldexp_f16_inline_constants`, `agc_driver_sdwa_ldexp_f16` and `agc_driver_float16_misc` pass. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-10 06:06:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:06:12Z.


Checked the 512 cells of LdexpF16InlineConstants on the HW oracle (gfx1035, the test's mode: IEEE=0, f32 denormals flushed, f16 kept): all match bit for bit. The new test fails without the change and passes with it on RADV. Merging.

The SDWA form is a separate, pre-existing issue: as @CouchRiv measured, and we see the same on gfx1035, SDWA src1 reads a float inline constant as its f16 bits zero-extended (src1_sel:WORD_0 with 0.5 gives +inf from 1.0, WORD_1 gives 1.0), while the recompiler still reads the f32 bits there. A follow-up PR for that path would be welcome.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094489372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1966#issuecomment-6094489372). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:06:12Z. --- Checked the 512 cells of `LdexpF16InlineConstants` on the HW oracle (gfx1035, the test's mode: IEEE=0, f32 denormals flushed, f16 kept): all match bit for bit. The new test fails without the change and passes with it on RADV. Merging. The SDWA form is a separate, pre-existing issue: as @CouchRiv measured, and we see the same on gfx1035, SDWA src1 reads a float inline constant as its f16 bits zero-extended (`src1_sel:WORD_0` with 0.5 gives +inf from 1.0, `WORD_1` gives 1.0), while the recompiler still reads the f32 bits there. A follow-up PR for that path would be welcome.
Sign in to join this conversation.
No reviewers
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
boykopovar/AnyPS5!1966
No description provided.