Skip to content

feat(shader): implement s_bfe_i64 - #838

Closed
ebosido444-ai wants to merge 1 commit into
boykopovar:mainfrom
ebosido444-ai:feat/shader-s-bfe-i64
Closed

ebosido444-ai wants to merge 1 commit into
boykopovar:mainfrom
ebosido444-ai:feat/shader-s-bfe-i64

Conversation

@ebosido444-ai

Copy link
Copy Markdown
Contributor

What

s_bfe_i64 (SOP2 0x2a) is the last SOP2 hole — shaders using a signed 64-bit bitfield extract die at translation with unsupported SOP2 opcode. Implemented as the sign twin of the existing s_bfe_u64, exactly the pairing of s_bfe_u32/s_bfe_i32: sBfeU64 widens to sBfeU64(inst, bool sign) over a shared extractBits64 (the clamp-and-mask the unsigned path already had, plus the sign-extension idiom the 32-bit pair uses), so the unsigned path is byte-equivalent for its callers and the two 32/64 families now read symmetrically. Shader progress: 1125 to 1126 out of 1166 on top of current main (1127 combined with #821).

Encoding sourced from LLVM's AMDGPU backend table SOP2_Real_gfx6_gfx7_gfx10_gfx13<0x02a> — the PS5 generation (gfx11/gfx12 renumber this family, so the row is generation-specific). Field descriptor layout (offset in bits 5:0, size in bits 22:16) is the one the existing s_bfe_u64 already decodes; sizes are clamped to the bits remaining above the offset as before, and the extracted field sign-extends from its top bit.

Tested

Windows 11: core/libs/tests/ScalarBfe64.cpp (registered as scalar_bfe64) decodes both 0x2a and 0x29 through DecodeRdnaSop2, asserts family and the two-dword destination bookkeeping (IsScalarAluOpcode accepted), translates both, and distinguishes them in the IR: ShiftRightArithmetic64 is present exactly for the signed form and the shared BitwiseAnd64 clamp present for both. Standalone run passes. Scoped CMake/CTest suite (winlibs GCC 15.2.0 per BUILD.md): scalar_bfe64, scalar_bitcount64, scalar_saveexec, guest_rtc — 4/4 passed. tools/progress.py: shaders 1125 -> 1126 out of 1166 on this branch.

Checklist

  • Based on current main; no other open PR implements the same functions (checked open-PR titles and diffs for BFE/bitfield — none)
  • 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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@github-actions github-actions Bot mentioned this pull request Oct 6, 2026
9 tasks done
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#234 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp L242
core/shader/recompiler/Translation/src/IntegerInstructions.cpp L675-679, L683-684

@ebosido444-ai

Copy link
Copy Markdown
Contributor Author

Closing in favour of #234, which implements the same function and predates this by five days (both converged on the same sBfeU64(inst, bool sign) widening and shift-align sign extension). #234 is complete with full-suite evidence. One process note for the record: my duplicate check missed #234 because a capped PR listing never reached it — the pr-overlap report above caught it. No functional difference worth merging here.

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