diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index baf67ff077f..ee938cd4118 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -2895,6 +2895,13 @@ bi_lower_branch(bi_block *block) if (bi_is_terminal_block(ins->branch_target)) ins->branch_target = NULL; + + /* If there is nowhere to go, there is no point in branching */ + if (bi_is_terminal_block((bi_block *) block->base.successors[0]) && + bi_is_terminal_block((bi_block *) block->base.successors[1]) && + ins->branch_target == NULL) { + bi_remove_instruction(ins); + } } }