From e159e0000cab2db16b39996bc9dd815bca8a2e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 18 Feb 2025 14:21:23 +0100 Subject: [PATCH] aco: don't assume that demote doesn't cause an empty exec mask Totals from 188 (0.24% of 79377) affected shaders: (Navi31) Instrs: 209239 -> 209473 (+0.11%); split: -0.01%, +0.12% CodeSize: 1101124 -> 1101744 (+0.06%); split: -0.02%, +0.07% Latency: 1672182 -> 1672748 (+0.03%); split: -0.11%, +0.14% InvThroughput: 237276 -> 237546 (+0.11%); split: -0.00%, +0.12% SClause: 5694 -> 5690 (-0.07%); split: -0.28%, +0.21% Copies: 21685 -> 21682 (-0.01%); split: -0.12%, +0.10% Branches: 5740 -> 5863 (+2.14%) PreSGPRs: 7004 -> 7034 (+0.43%) VALU: 123595 -> 123641 (+0.04%); split: -0.00%, +0.04% SALU: 28418 -> 28411 (-0.02%); split: -0.09%, +0.06% Fixes: f35e229faedb5e19da49846eed119d82228c5d5a ('aco: skip code if exec is empty') Part-of: (cherry picked from commit 69dcd5be3a94d8c301ebf54f7e043f419841a231) --- .pick_status.json | 2 +- src/amd/compiler/aco_instruction_selection.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 81bf549a8f5..f5957207f26 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1674,7 +1674,7 @@ "description": "aco: don't assume that demote doesn't cause an empty exec mask", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f35e229faedb5e19da49846eed119d82228c5d5a", "notes": null diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 66b9cbc4f45..7c8c3ecddb6 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -8646,6 +8646,11 @@ visit_intrinsic(isel_context* ctx, nir_intrinsic_instr* instr) if (ctx->shader->info.maximally_reconverges) ctx->program->needs_wqm = true; + if (ctx->block->loop_nest_depth || ctx->cf_info.parent_if.is_divergent) { + ctx->cf_info.exec.potentially_empty_discard = true; + begin_empty_exec_skip(ctx, &instr->instr, instr->instr.block); + } + break; } case nir_intrinsic_terminate: