From ded35729475b91685b66b2e0efb27c95a9ae2f0e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 1 Nov 2022 18:12:19 -0700 Subject: [PATCH] nir: Use nir_type_convert instead of nir_type_conversion_op 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 Part-of: --- src/compiler/nir/nir_conversion_builder.h | 7 +++---- src/compiler/nir/nir_lower_alu.c | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/compiler/nir/nir_conversion_builder.h b/src/compiler/nir/nir_conversion_builder.h index 21d8e8b..bb623f1 100644 --- a/src/compiler/nir/nir_conversion_builder.h +++ b/src/compiler/nir/nir_conversion_builder.h @@ -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; diff --git a/src/compiler/nir/nir_lower_alu.c b/src/compiler/nir/nir_lower_alu.c index d0cc7b5..3b0dbaa 100644 --- a/src/compiler/nir/nir_lower_alu.c +++ b/src/compiler/nir/nir_lower_alu.c @@ -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); -- 2.7.4