diff --git a/src/amd/compiler/aco_lower_branches.cpp b/src/amd/compiler/aco_lower_branches.cpp index 443decfa9b5..f4d36566f46 100644 --- a/src/amd/compiler/aco_lower_branches.cpp +++ b/src/amd/compiler/aco_lower_branches.cpp @@ -379,6 +379,10 @@ can_remove_branch(branch_ctx& ctx, Block& block, Pseudo_branch_instruction* bran if (uniform_branch && !ctx.program->blocks[i].instructions.empty()) return false; + /* Don't enter loops with empty exec mask. */ + if (ctx.program->blocks[i].loop_nest_depth > block.loop_nest_depth) + return false; + for (aco_ptr& instr : ctx.program->blocks[i].instructions) { if (instr->isSOPP()) { /* Discard early exits and loop breaks and continues should work fine with