Mesa (refs/tags/chadv/cros-mesa-19.0-r1-vanilla): nir/spirv: return after emitting a branch in block

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 29 22:53:37 UTC 2020


Module: Mesa
Branch: refs/tags/chadv/cros-mesa-19.0-r1-vanilla
Commit: b43b55d4619489e603780adf3c92a36dadcc362b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b43b55d4619489e603780adf3c92a36dadcc362b

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Wed Feb 27 10:42:00 2019 +0000

nir/spirv: return after emitting a branch in block

When emitting a branch in a block, it does not make sense to continue
processing further instructions, as they will not be reachable.

This fixes a nasty case with a loop with a branch that both then-part
and else-part exits the loop:

%1 = OpLabel
     OpLoopMerge %2 %3 None
     OpBranchConditional %false %2 %2
%3 = OpLabel
     OpBranch %1
%2 = OpLabel
    [...]

We know that block %1 will branch always to block %2, which is the merge
block for the loop. And thus a break is emitted. If we keep continuing
processing further instructions, we will be processing the branch
conditional and thus emitting the proper NIR conditional, which leads to
instructions after the break.

This fixes dEQP-VK.graphicsfuzz.continue-and-merge.

CC: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/compiler/spirv/vtn_cfg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index c32d54e9006..7868eeb60bc 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -916,6 +916,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list,
          if (block->branch_type != vtn_branch_type_none) {
             vtn_emit_branch(b, block->branch_type,
                             switch_fall_var, has_switch_break);
+            return;
          }
 
          break;



More information about the mesa-commit mailing list