jay: Remember sp_delta_B when rematerializing stack pointer lane 0

The stack pointer starts out at b.shader->scratch_size, plus per-lane
offsets.  Every time we spill/fill, we adjust the stack pointer to
the offset for our desired memory location, and leave it there.  Over
the course of each block's spills/fills, we track the current delta from
the original value, and restore it to there at the end of the block.

However, when we started clobbering lane 0 and rematerializing it,
we were recreating it as the original base value (b.shader->scratch_size
+ sizeof(uint32_t) * 0).  We need to include sp_delta_B too, or else we
will calculate our deltas incorrectly for that lane, and restore it
incorrectly at the end of the block too.

Found while debugging the issue fixed by the previous commit.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41872>
This commit is contained in:
Kenneth Graunke 2026-06-02 02:29:28 -07:00 committed by Marge Bot
parent 5e157f3e6a
commit 65697d6438

View file

@ -116,7 +116,7 @@ jay_lower_spill(jay_function *func)
if (I->op == JAY_OPCODE_MOV && jay_is_send_like(I)) {
if (!address_valid) {
jay_MOV(&b, ADDRESS_REG, tmpu);
jay_MOV(&b, tmpu, b.shader->scratch_size);
jay_MOV(&b, tmpu, b.shader->scratch_size + sp_delta_B);
address_valid = true;
}
@ -140,7 +140,7 @@ jay_lower_spill(jay_function *func)
if (jay_num_successors(block, GPR) > 0) {
if (!address_valid) {
jay_MOV(&b, ADDRESS_REG, tmpu);
jay_MOV(&b, tmpu, b.shader->scratch_size);
jay_MOV(&b, tmpu, b.shader->scratch_size + sp_delta_B);
}
if (sp_delta_B > 0) {