Mesa (master): spirv: consider bitsize when handling OpSwitch cases
Jason Ekstrand
jekstrand at kemper.freedesktop.org
Thu Dec 28 18:39:35 UTC 2017
Module: Mesa
Branch: master
Commit: 5c5f2eaa08fb6c1b1241c424dd4b33d326a15b7d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c5f2eaa08fb6c1b1241c424dd4b33d326a15b7d
Author: Eero Tamminen <eero.t.tamminen at intel.com>
Date: Tue Dec 26 07:21:21 2017 -0800
spirv: consider bitsize when handling OpSwitch cases
This reverts commit 7665383a33f9ce9256aa121cbe4d3bd948dff145 and is
squashed together with https://patchwork.freedesktop.org/patch/194610/
(spirv: avoid infinite loop / freeze in vtn_cfg_walk_blocks()) which
fixes https://bugs.freedesktop.org/show_bug.cgi?id=104359 properly.
Fixes: 9702fac68e (spirv: consider bitsize when handling OpSwitch cases)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104359
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/spirv/vtn_cfg.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 8582c4f0e9..3d5de378ac 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -513,13 +513,14 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,
"Selector of OpSelect must have a type of OpTypeInt");
bool is_default = true;
+ const uint bitsize = nir_alu_type_get_type_size(cond_type);
for (const uint32_t *w = block->branch + 2; w < branch_end;) {
uint64_t literal = 0;
if (!is_default) {
- if (nir_alu_type_get_type_size(cond_type) <= 32) {
+ if (bitsize <= 32) {
literal = *(w++);
} else {
- assert(nir_alu_type_get_type_size(cond_type) == 64);
+ assert(bitsize == 64);
literal = vtn_u64_literal(w);
w += 2;
}
@@ -544,10 +545,17 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,
/* Finally, we walk over all of the cases one more time and put
* them in fall-through order.
*/
- for (const uint32_t *w = block->branch + 2; w < branch_end; w += 2) {
+ for (const uint32_t *w = block->branch + 2; w < branch_end;) {
struct vtn_block *case_block =
vtn_value(b, *w, vtn_value_type_block)->block;
+ if (bitsize <= 32) {
+ w += 2;
+ } else {
+ assert(bitsize == 64);
+ w += 3;
+ }
+
if (case_block == break_block)
continue;
More information about the mesa-commit
mailing list