From: Jason Ekstrand Date: Fri, 29 May 2020 04:00:21 +0000 (-0500) Subject: spirv: Use nir_bany/ball for OpAny/All X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=953b7a36032207edde5d7cb729d4e5bb34d07bf8;p=mesa.git spirv: Use nir_bany/ball for OpAny/All Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- 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: {