freedreno/ir3: Fold 16-bit conversions into image load/store src/dsts.
authorEmma Anholt <emma@anholt.net>
Thu, 19 May 2022 20:41:34 +0000 (13:41 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 1 Jun 2022 22:19:44 +0000 (22:19 +0000)
Shaves 5 instructions off of one manhattan31 shader.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16616>

src/freedreno/ir3/ir3_image.c
src/freedreno/ir3/ir3_nir.c

index 23a3439..f52c188 100644 (file)
@@ -116,7 +116,7 @@ type_t
 ir3_get_type_for_image_intrinsic(const nir_intrinsic_instr *instr)
 {
    const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
-   int bit_size = info->has_dest ? nir_dest_bit_size(instr->dest) : 32;
+   int bit_size = info->has_dest ? nir_dest_bit_size(instr->dest) : nir_src_bit_size(instr->src[3]);
 
    nir_alu_type type = nir_type_uint;
    switch (instr->intrinsic) {
index 1b6bbe5..1fbc113 100644 (file)
@@ -755,6 +755,8 @@ ir3_nir_lower_variant(struct ir3_shader_variant *so, nir_shader *s)
             (1 << nir_tex_src_ddy),
             ~0);
 
+         OPT(s, nir_fold_16bit_image_load_store_conversions);
+
          /* Now that we stripped off the 16-bit conversions, legalize so that we
           * don't have a mix of 16- and 32-bit args that will need to be
           * collected together in the coordinate vector.