From 29c63de0620e28b2595720d907e1c3cc60da717b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 3 Dec 2024 18:54:25 +0100 Subject: [PATCH] aco/jump_threading: don't remove loop preheaders They might be needed as convergence point in order to insert code (e.g. for loop alignment, wait states, etc.). Totals from 1 (0.00% of 79395) affected shaders: CodeSize: 12672 -> 12716 (+0.35%) Part-of: --- src/amd/compiler/aco_jump_threading.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/amd/compiler/aco_jump_threading.cpp b/src/amd/compiler/aco_jump_threading.cpp index c973417986f..aaf0b6e6806 100644 --- a/src/amd/compiler/aco_jump_threading.cpp +++ b/src/amd/compiler/aco_jump_threading.cpp @@ -109,6 +109,12 @@ try_remove_simple_block(jump_threading_ctx& ctx, Block* block) if (!is_empty_block(block, false)) return; + /* Don't remove the preheader as it might be needed as convergence point + * in order to insert code (e.g. for loop alignment, wait states, etc.). + */ + if (block->kind & block_kind_loop_preheader) + return; + Block& pred = ctx.program->blocks[block->linear_preds[0]]; Block& succ = ctx.program->blocks[block->linear_succs[0]]; Pseudo_branch_instruction& branch = pred.instructions.back()->branch();