fix(recompiler): widen constants of 64-bit operands instead of repeating them #39
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/39"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-09-27T17:00:16Z.
Problem
TranslationContext::readU32Pairbuilds a 64-bit source from two 32-bit reads, taking the high half fromoffsetOperand(operand, 1). For registers that is the next register. For a literal or an inline constant,offsetOperandreturns the same operand, so the constant ended up in both halves: the literalLwas read asL:Linstead of0:L.Found in The Smurfs Dreams (UE). A compute shader writes the args of an indirect draw and rounds a count up to a multiple of 21:
With the addend read as
0xc30c30c3c30c30c3, the draw got0x0c30c30dinstances instead of 0. On RDNA2 that kept the gfx ring busy past the amdgpu lockup timeout, and a MODE1 GPU reset followed.Fix
The fix only applies when the operand is a constant:
-1becomes all onesRegister operands behave as before.
The same function backs
readMask, so a 64-bit mask constant also changes. For example,s_and_saveexec_b64 s[14:15], 1in a wave64 shader enabled lanes 0 and 32. Now it enables only lane 0.Testing
libson Linux;ctestpasses 36/36.{63, 0, 0, 0}, the draw is skipped as intended, and there has been no reset or GPU fault in a 240 s run.🤖 Generated with Claude Code