From a496b41d50589191ad2e37a17019aef0dafcb9f2 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 18 Feb 2021 13:53:33 -0500 Subject: [PATCH] pan/bi: Optimize out redundant jumps to #0x0 If it's the last instruction, that's silly. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index baf67ff..ee938cd 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); + } } } -- 2.7.4