Mesa (staging/22.0): spirv: fix OpBranchConditional when both branches are the same
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 22:22:08 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: a2397acde470c7eb2d7c7ccf3354b09926ca6c2e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2397acde470c7eb2d7c7ccf3354b09926ca6c2e
Author: Alexey Bozhenko <oleksii.bozhenko at globallogic.com>
Date: Wed Apr 13 15:16:16 2022 +0300
spirv: fix OpBranchConditional when both branches are the same
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6246
Signed-off-by: Bozhenko Alexey <oleksii.bozhenko at globallogic.com>
Fixes: 64cb143b922 ("spirv: Fix handling of OpBranchConditional with same THEN and ELSE")
Reviewed-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15929>
(cherry picked from commit 25acf1d8697ae62a2eead1bca9e5f8ca6eb2b372)
---
.pick_status.json | 2 +-
src/compiler/spirv/vtn_cfg.c | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index d23b55157cb..81628765f4a 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -100,7 +100,7 @@
"description": "spirv: fix OpBranchConditional when both branches are the same",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"because_sha": "64cb143b922b4c074a8404359e7ed9b790941744"
},
{
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 2bf698629c1..53b6e317e34 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -1093,17 +1093,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]));
More information about the mesa-commit
mailing list