aco/optimizer_postRA: assume all registers are untrackable in loop headers

Register writes from the pre-header might not be correct for any but
the first loop iteration because they can be clobbered inside the loop.

Foz-DB Navi21:
Totals from 18 (0.01% of 134913) affected shaders:
CodeSize: 251384 -> 251508 (+0.05%)
Instrs: 47644 -> 47664 (+0.04%)
Latency: 801801 -> 801852 (+0.01%)
InvThroughput: 177579 -> 177593 (+0.01%)
Copies: 4752 -> 4771 (+0.40%)

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8376
Fixes: d3b0f78110 ("aco/optimizer_postRA: Initialize loop header with preheader information")

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21540>
This commit is contained in:
Georg Lehmann 2023-02-26 15:54:18 +01:00 committed by Marge Bot
parent 4c978d5445
commit e1eabab6fe

View file

@ -109,13 +109,13 @@ struct pr_opt_ctx {
std::fill(instr_idx_by_regs[block->index].begin(), instr_idx_by_regs[block->index].end(),
not_written_yet);
} else if (block->kind & block_kind_loop_header) {
/* Initialize with content from loop preheader */
memcpy(&instr_idx_by_regs[block->index][0], &instr_idx_by_regs[block->index - 1][0],
max_reg_cnt * sizeof(Idx));
/* Assume exec writes on back-edges */
instr_idx_by_regs[block->index][126] = overwritten_untrackable;
instr_idx_by_regs[block->index][127] = overwritten_untrackable;
/* Instructions inside the loop may overwrite registers of temporaries that are
* not live inside the loop, but we can't detect that because we haven't processed
* the blocks in the loop yet. As a workaround, mark all registers as untrackable.
* TODO: Consider improving this in the future.
*/
std::fill(instr_idx_by_regs[block->index].begin(), instr_idx_by_regs[block->index].end(),
overwritten_untrackable);
} else {
reset_block_regs(block->linear_preds, block->index, 0, max_sgpr_cnt);
reset_block_regs(block->linear_preds, block->index, 251, 3);