spirv: Use nir_bany/ball for OpAny/All
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 29 May 2020 04:00:21 +0000 (23:00 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Fri, 24 Jul 2020 03:43:20 +0000 (22:43 -0500)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5278>

src/compiler/nir/nir_builder.h
src/compiler/spirv/vtn_alu.c

index 283eb2b1f198dcb73fd138f5db8fbe4630f7cbdb..fd7a45a8d8cd334c315f8f781533052525cc1b3f 100644 (file)
@@ -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)
 {
index 611f186c3015a4cf7a22dc5fc10dd82f5701aca5..9ebadba9b2a54aa31a2869648a0fbed6ca8538a9 100644 (file)
@@ -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: {