spirv: Clean up OpSignBitSet
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 28 May 2020 22:14:30 +0000 (17:14 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Fri, 24 Jul 2020 03:41:54 +0000 (22:41 -0500)
For some reason, we were doing a signed shift vectors and an unsigned
shift for scalars.  We then plug it into i2b so it should make no
difference whatsoever.  The fact that we're doing different things for
vectors vs. scalars is bonkers.  Let's simplify the code a bit.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5278>

src/compiler/spirv/vtn_alu.c

index e78f74576bbed0a1811d86a60aded16822d515e0..611f186c3015a4cf7a22dc5fc10dd82f5701aca5 100644 (file)
@@ -646,18 +646,10 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
       break;
    }
 
-   case SpvOpSignBitSet: {
-      unsigned src_bit_size = glsl_get_bit_size(vtn_src[0]->type);
-      if (src[0]->num_components == 1)
-         val->ssa->def =
-            nir_ushr(&b->nb, src[0], nir_imm_int(&b->nb, src_bit_size - 1));
-      else
-         val->ssa->def =
-            nir_ishr(&b->nb, src[0], nir_imm_int(&b->nb, src_bit_size - 1));
-
-      val->ssa->def = nir_i2b(&b->nb, val->ssa->def);
+   case SpvOpSignBitSet:
+      val->ssa->def = nir_i2b(&b->nb,
+         nir_ushr(&b->nb, src[0], nir_imm_int(&b->nb, src[0]->bit_size - 1)));
       break;
-   }
 
    case SpvOpUCountTrailingZerosINTEL:
       val->ssa->def = nir_umin(&b->nb,