Mesa (master): nir/spirv: handle if's with same label in both branches
Samuel Iglesias Gonsálvez
samuelig at kemper.freedesktop.org
Tue Sep 12 05:02:07 UTC 2017
Module: Mesa
Branch: master
Commit: 806ae6a648326327ead48d1b9aec6f44f74f06f9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=806ae6a648326327ead48d1b9aec6f44f74f06f9
Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date: Thu Aug 24 17:16:04 2017 +0200
nir/spirv: handle if's with same label in both branches
When a conditional branch has the same labels in the "if" part and in the
"else" part, then we have the same cfg block, and it must be handled
once.
v2: handle it the same way as OpBranch (Jason).
Fixes:
dEQP-VK.spirv_assembly.instruction.compute.conditional_branch.same_labels*
dEQP-VK.spirv_assembly.instruction.graphics.conditional_branch.same_labels*
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/spirv/vtn_cfg.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 03c452cb31..3ad20b9ad8 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -356,8 +356,16 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,
switch_case, switch_break,
loop_break, loop_cont);
- if (if_stmt->then_type == vtn_branch_type_none &&
- if_stmt->else_type == vtn_branch_type_none) {
+ if (then_block == else_block) {
+ block->branch_type = if_stmt->then_type;
+ if (block->branch_type == vtn_branch_type_none) {
+ block = then_block;
+ continue;
+ } else {
+ return;
+ }
+ } else if (if_stmt->then_type == vtn_branch_type_none &&
+ if_stmt->else_type == vtn_branch_type_none) {
/* Neither side of the if is something we can short-circuit. */
assert((*block->merge & SpvOpCodeMask) == SpvOpSelectionMerge);
struct vtn_block *merge_block =
More information about the mesa-commit
mailing list