From 25acf1d8697ae62a2eead1bca9e5f8ca6eb2b372 Mon Sep 17 00:00:00 2001 From: Alexey Bozhenko Date: Wed, 13 Apr 2022 15:16:16 +0300 Subject: [PATCH] spirv: fix OpBranchConditional when both branches are the same Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6246 Signed-off-by: Bozhenko Alexey Fixes: 64cb143b922 ("spirv: Fix handling of OpBranchConditional with same THEN and ELSE") Reviewed-by: Caio Oliveira Part-of: --- src/compiler/spirv/vtn_cfg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c index d408e2437ed..e0f88322f6a 100644 --- a/src/compiler/spirv/vtn_cfg.c +++ b/src/compiler/spirv/vtn_cfg.c @@ -1128,17 +1128,20 @@ vtn_emit_cf_list_structured(struct vtn_builder *b, struct list_head *cf_list, const uint32_t *branch = vtn_if->header_block->branch; vtn_assert((branch[0] & SpvOpCodeMask) == SpvOpBranchConditional); + bool sw_break = false; /* If both branches are the same, just emit the first block, which is * the only one we filled when building the CFG. */ if (branch[2] == branch[3]) { - vtn_emit_cf_list_structured(b, &vtn_if->then_body, - switch_fall_var, has_switch_break, handler); + if (vtn_if->then_type == vtn_branch_type_none) { + vtn_emit_cf_list_structured(b, &vtn_if->then_body, + switch_fall_var, &sw_break, handler); + } else { + vtn_emit_branch(b, vtn_if->then_type, switch_fall_var, &sw_break); + } break; } - bool sw_break = false; - nir_if *nif = nir_push_if(&b->nb, vtn_get_nir_ssa(b, branch[1]));