nir/load_const_to_scalar: Get rid of a bit size switch statement
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 27 Mar 2019 23:31:01 +0000 (18:31 -0500)
committerKarol Herbst <kherbst@redhat.com>
Sun, 14 Apr 2019 20:25:56 +0000 (22:25 +0200)
Now that nir_const_value is a scalar, we don't need the switch on bit
size in order to pluck off components properly.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
src/compiler/nir/nir_lower_load_const_to_scalar.c

index 47dc83613ef3b76686d9aaea31bb0f811f0b12a3..a65dcb06d0cad68dc18b390ed2d8a8650e616391 100644 (file)
@@ -50,25 +50,7 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)
    for (unsigned i = 0; i < lower->def.num_components; i++) {
       nir_load_const_instr *load_comp =
          nir_load_const_instr_create(b.shader, 1, lower->def.bit_size);
-      switch (lower->def.bit_size) {
-      case 64:
-         load_comp->value[0].u64 = lower->value[i].u64;
-         break;
-      case 32:
-         load_comp->value[0].u32 = lower->value[i].u32;
-         break;
-      case 16:
-         load_comp->value[0].u16 = lower->value[i].u16;
-         break;
-      case 8:
-         load_comp->value[0].u8 = lower->value[i].u8;
-         break;
-      case 1:
-         load_comp->value[0].b = lower->value[i].b;
-         break;
-      default:
-         assert(!"invalid bit size");
-      }
+      load_comp->value[0] = lower->value[i];
       nir_builder_instr_insert(&b, &load_comp->instr);
       loads[i] = &load_comp->def;
    }