summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv/spirv_to_nir.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-03-11 18:58:24 -0500
committerJason Ekstrand <[email protected]>2019-03-15 23:10:26 -0500
commitfe9a6c0f14aa3ca6dfb1c7480871c95838b5cf14 (patch)
tree5cbbefe919ad7886b7df6abe739f592d82b9a32a /src/compiler/spirv/spirv_to_nir.c
parent9bb63e9a7c57f164a9d453ba33347d803e453144 (diff)
nir/builder: Add a vector extract helper
This one's a tiny bit better than what we had in spirv_to_nir because it emits a binary tree rather than a linear walk. It also doesn't leave around unneeded bcsel instructions for a constant index and returns an undef for constant OOB access. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler/spirv/spirv_to_nir.c')
-rw-r--r--src/compiler/spirv/spirv_to_nir.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index da0f2dcd805..3b7f8d8a9ac 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3047,12 +3047,7 @@ nir_ssa_def *
vtn_vector_extract_dynamic(struct vtn_builder *b, nir_ssa_def *src,
nir_ssa_def *index)
{
- nir_ssa_def *dest = vtn_vector_extract(b, src, 0);
- for (unsigned i = 1; i < src->num_components; i++)
- dest = nir_bcsel(&b->nb, nir_ieq_imm(&b->nb, index, i),
- vtn_vector_extract(b, src, i), dest);
-
- return dest;
+ return nir_vector_extract(&b->nb, src, nir_i2i(&b->nb, index, 32));
}
nir_ssa_def *