From c4217ef2fc73576aee636d7c8cc4e4d7e94f33cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 11 Dec 2020 17:44:19 +0100 Subject: [PATCH] aco: don't create dead exec mask phis on merge blocks Avoids some unnecessary exec copies and allows for a bit more jump threading. Totals from 112 (0.08% of 139391) affected shaders (NAVI10): SpillSGPRs: 3084 -> 3050 (-1.10%) CodeSize: 2657516 -> 2652376 (-0.19%) Instrs: 492074 -> 490824 (-0.25%) Cycles: 40369704 -> 40317052 (-0.13%) VMEM: 24212 -> 24128 (-0.35%) SClause: 12018 -> 12010 (-0.07%) Copies: 72950 -> 72275 (-0.93%) Branches: 13249 -> 12701 (-4.14%) Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_insert_exec_mask.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_insert_exec_mask.cpp b/src/amd/compiler/aco_insert_exec_mask.cpp index a027aca857f..6bb5c831cf6 100644 --- a/src/amd/compiler/aco_insert_exec_mask.cpp +++ b/src/amd/compiler/aco_insert_exec_mask.cpp @@ -590,7 +590,10 @@ unsigned add_coupling_code(exec_ctx& ctx, Block* block, /* if one of the predecessors ends in exact mask, we pop it from stack */ unsigned num_exec_masks = std::min(ctx.info[preds[0]].exec.size(), ctx.info[preds[1]].exec.size()); - if (block->kind & block_kind_top_level && !(block->kind & block_kind_merge)) + + if (block->kind & block_kind_merge) + num_exec_masks--; + else if (block->kind & block_kind_top_level) num_exec_masks = std::min(num_exec_masks, 2u); /* create phis for diverged exec masks */ @@ -617,9 +620,6 @@ unsigned add_coupling_code(exec_ctx& ctx, Block* block, i++; } - if (block->kind & block_kind_merge) - ctx.info[idx].exec.pop_back(); - if (block->kind & block_kind_top_level && ctx.info[idx].exec.size() == 3) { assert(ctx.info[idx].exec.back().second == mask_type_exact); assert(block->kind & block_kind_merge);