nir: Use nir_type_convert instead of nir_type_conversion_op
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 2 Nov 2022 01:12:19 +0000 (18:12 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 14 Dec 2022 06:23:21 +0000 (06:23 +0000)
In a future commit, nit_type_conversion_op won't be able to handle i2b
(and in a much later commit f2b), so switch many users to the fully
featured function.

No shader-db or fossil-db changes on any Intel platform.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15121>

src/compiler/nir/nir_conversion_builder.h
src/compiler/nir/nir_lower_alu.c

index 21d8e8b..bb623f1 100644 (file)
@@ -480,10 +480,9 @@ nir_convert_with_rounding(nir_builder *b,
    } else {
       trivial_convert = false;
    }
-   if (trivial_convert) {
-      nir_op op = nir_type_conversion_op(src_type, dest_type, round);
-      return nir_build_alu(b, op, src, NULL, NULL, NULL);
-   }
+
+   if (trivial_convert)
+      return nir_type_convert(b, src, src_type, dest_type, round);
 
    nir_ssa_def *dest = src;
 
index d0cc7b5..3b0dbaa 100644 (file)
@@ -143,14 +143,12 @@ lower_alu_instr(nir_builder *b, nir_instr *instr_, UNUSED void *cb_data)
          if (src0->bit_size < 32) {
             /* Just do the math in 32-bit space and shift the result */
             nir_alu_type base_type = nir_op_infos[instr->op].output_type;
-            nir_op upcast_op = nir_type_conversion_op(base_type | src0->bit_size, base_type | 32, nir_rounding_mode_undef);
-            nir_op downscast_op = nir_type_conversion_op(base_type | 32, base_type | src0->bit_size, nir_rounding_mode_undef);
 
-            nir_ssa_def *src0_32 = nir_build_alu(b, upcast_op, src0, NULL, NULL, NULL);
-            nir_ssa_def *src1_32 = nir_build_alu(b, upcast_op, src1, NULL, NULL, NULL);
+            nir_ssa_def *src0_32 = nir_type_convert(b, src0, base_type, base_type | 32, nir_rounding_mode_undef);
+            nir_ssa_def *src1_32 = nir_type_convert(b, src1, base_type, base_type | 32, nir_rounding_mode_undef);
             nir_ssa_def *dest_32 = nir_imul(b, src0_32, src1_32);
             nir_ssa_def *dest_shifted = nir_ishr(b, dest_32, nir_imm_int(b, src0->bit_size));
-            lowered = nir_build_alu(b, downscast_op, dest_shifted, NULL, NULL, NULL);
+            lowered = nir_type_convert(b, dest_shifted, base_type, base_type | src0->bit_size, nir_rounding_mode_undef);
          } else {
             nir_ssa_def *cshift = nir_imm_int(b, src0->bit_size / 2);
             nir_ssa_def *cmask = nir_imm_intN_t(b, (1ull << (src0->bit_size / 2)) - 1, src0->bit_size);