Module: Mesa Branch: staging/23.2 Commit: 265a822e9d8dae03e464cf775d286ed4f2cd39c2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=265a822e9d8dae03e464cf775d286ed4f2cd39c2
Author: Rhys Perry <[email protected]> Date: Wed Sep 20 19:27:39 2023 +0100 aco: reset prefetch in the correct block after removing the exit fossil-db (navi31): Totals from 279 (0.35% of 79332) affected shaders: (no stat changes) Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Daniel Schürmann <[email protected]> Fixes: c778803d673f ("aco/assembler: change prefetch mode on GFX10.3+ during loops if beneficial") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25312> (cherry picked from commit 21db2e701746fca5d5be0b7135a1bd6c7345e789) --- .pick_status.json | 2 +- src/amd/compiler/aco_assembler.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8d0eddbfd96..27778b357f3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -14,7 +14,7 @@ "description": "aco: reset prefetch in the correct block after removing the exit", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "c778803d673f8db16df5951637258405b2d7e0a6", "notes": null diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp index cd778eb3a81..6e9a08822df 100644 --- a/src/amd/compiler/aco_assembler.cpp +++ b/src/amd/compiler/aco_assembler.cpp @@ -48,7 +48,7 @@ struct asm_context { std::map<unsigned, constaddr_info> constaddrs; std::map<unsigned, constaddr_info> resumeaddrs; std::vector<struct aco_symbol>* symbols; - Block* loop_header; + Block* loop_header = NULL; const int16_t* opcode; // TODO: keep track of branch instructions referring blocks // and, when emitting the block, correct the offset in instr @@ -1221,7 +1221,11 @@ fix_constaddrs(asm_context& ctx, std::vector<uint32_t>& out) void align_block(asm_context& ctx, std::vector<uint32_t>& code, Block& block) { - if (block.kind & block_kind_loop_exit && ctx.loop_header) { + /* Blocks with block_kind_loop_exit might be eliminated after jump threading, so we instead find + * loop exits using loop_nest_depth. + */ + if (ctx.loop_header && !block.linear_preds.empty() && + block.loop_nest_depth < ctx.loop_header->loop_nest_depth) { Block* loop_header = ctx.loop_header; ctx.loop_header = NULL; std::vector<uint32_t> nops;
