From 953b7a36032207edde5d7cb729d4e5bb34d07bf8 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 28 May 2020 23:00:21 -0500 Subject: [PATCH] spirv: Use nir_bany/ball for OpAny/All Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- src/compiler/nir/nir_builder.h | 6 ++++++ src/compiler/spirv/vtn_alu.c | 34 ++-------------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 283eb2b1f19..fd7a45a8d8c 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -537,6 +537,12 @@ nir_ball_iequal(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1) } } +static inline nir_ssa_def * +nir_ball(nir_builder *b, nir_ssa_def *src) +{ + return nir_ball_iequal(b, src, nir_imm_true(b)); +} + static inline nir_ssa_def * nir_bany_inequal(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1) { diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c index 611f186c301..9ebadba9b2a 100644 --- a/src/compiler/spirv/vtn_alu.c +++ b/src/compiler/spirv/vtn_alu.c @@ -442,41 +442,11 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode, switch (opcode) { case SpvOpAny: - if (src[0]->num_components == 1) { - val->ssa->def = nir_mov(&b->nb, src[0]); - } else { - nir_op op; - switch (src[0]->num_components) { - case 2: op = nir_op_bany_inequal2; break; - case 3: op = nir_op_bany_inequal3; break; - case 4: op = nir_op_bany_inequal4; break; - case 8: op = nir_op_bany_inequal8; break; - case 16: op = nir_op_bany_inequal16; break; - default: vtn_fail("invalid number of components"); - } - val->ssa->def = nir_build_alu(&b->nb, op, src[0], - nir_imm_false(&b->nb), - NULL, NULL); - } + val->ssa->def = nir_bany(&b->nb, src[0]); break; case SpvOpAll: - if (src[0]->num_components == 1) { - val->ssa->def = nir_mov(&b->nb, src[0]); - } else { - nir_op op; - switch (src[0]->num_components) { - case 2: op = nir_op_ball_iequal2; break; - case 3: op = nir_op_ball_iequal3; break; - case 4: op = nir_op_ball_iequal4; break; - case 8: op = nir_op_ball_iequal8; break; - case 16: op = nir_op_ball_iequal16; break; - default: vtn_fail("invalid number of components"); - } - val->ssa->def = nir_build_alu(&b->nb, op, src[0], - nir_imm_true(&b->nb), - NULL, NULL); - } + val->ssa->def = nir_ball(&b->nb, src[0]); break; case SpvOpOuterProduct: { -- 2.30.2