diff --git a/src/compiler/nir/nir_builder.c b/src/compiler/nir/nir_builder.c index b35776b2a67..1d41638fdc8 100644 --- a/src/compiler/nir/nir_builder.c +++ b/src/compiler/nir/nir_builder.c @@ -436,7 +436,8 @@ nir_ssa_def * nir_type_convert(nir_builder *b, nir_ssa_def *src, nir_alu_type src_type, - nir_alu_type dest_type) + nir_alu_type dest_type, + nir_rounding_mode rnd) { assert(nir_alu_type_get_type_size(src_type) == 0 || nir_alu_type_get_type_size(src_type) == src->bit_size); @@ -444,7 +445,7 @@ nir_type_convert(nir_builder *b, src_type = (nir_alu_type) (src_type | src->bit_size); nir_op opcode = - nir_type_conversion_op(src_type, dest_type, nir_rounding_mode_undef); + nir_type_conversion_op(src_type, dest_type, rnd); if (opcode == nir_op_mov) return src; diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 9fad861f27f..d954cb98803 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -369,7 +369,8 @@ nir_ssa_def * nir_type_convert(nir_builder *b, nir_ssa_def *src, nir_alu_type src_type, - nir_alu_type dest_type); + nir_alu_type dest_type, + nir_rounding_mode rnd); static inline nir_ssa_def * nir_convert_to_bit_size(nir_builder *b, @@ -377,7 +378,8 @@ nir_convert_to_bit_size(nir_builder *b, nir_alu_type type, unsigned bit_size) { - return nir_type_convert(b, src, type, (nir_alu_type) (type | bit_size)); + return nir_type_convert(b, src, type, (nir_alu_type) (type | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * @@ -407,7 +409,8 @@ nir_f2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) static inline nir_ssa_def * nir_f2b(nir_builder *b, nir_ssa_def *src) { - return nir_type_convert(b, src, nir_type_float, nir_type_bool1); + return nir_type_convert(b, src, nir_type_float, nir_type_bool1, + nir_rounding_mode_undef); } static inline nir_ssa_def * @@ -420,42 +423,48 @@ static inline nir_ssa_def * nir_b2iN(nir_builder *b, nir_ssa_def *src, uint32_t bit_size) { return nir_type_convert(b, src, nir_type_bool, - (nir_alu_type) (nir_type_int | bit_size)); + (nir_alu_type) (nir_type_int | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * nir_b2fN(nir_builder *b, nir_ssa_def *src, uint32_t bit_size) { return nir_type_convert(b, src, nir_type_bool, - (nir_alu_type) (nir_type_float | bit_size)); + (nir_alu_type) (nir_type_float | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * nir_i2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_int, - (nir_alu_type) (nir_type_float | bit_size)); + (nir_alu_type) (nir_type_float | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * nir_u2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_uint, - (nir_alu_type) (nir_type_float | bit_size)); + (nir_alu_type) (nir_type_float | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * nir_f2uN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_float, - (nir_alu_type) (nir_type_uint | bit_size)); + (nir_alu_type) (nir_type_uint | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * nir_f2iN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_float, - (nir_alu_type) (nir_type_int | bit_size)); + (nir_alu_type) (nir_type_int | bit_size), + nir_rounding_mode_undef); } static inline nir_ssa_def * diff --git a/src/compiler/nir/nir_lower_idiv.c b/src/compiler/nir/nir_lower_idiv.c index 50840e0d911..92a24e85908 100644 --- a/src/compiler/nir/nir_lower_idiv.c +++ b/src/compiler/nir/nir_lower_idiv.c @@ -99,8 +99,8 @@ convert_instr_small(nir_builder *b, nir_op op, nir_alu_type int_type = nir_op_infos[op].output_type | sz; nir_alu_type float_type = nir_type_float | (options->allow_fp16 ? sz * 2 : 32); - nir_ssa_def *p = nir_type_convert(b, numer, int_type, float_type); - nir_ssa_def *q = nir_type_convert(b, denom, int_type, float_type); + nir_ssa_def *p = nir_type_convert(b, numer, int_type, float_type, nir_rounding_mode_undef); + nir_ssa_def *q = nir_type_convert(b, denom, int_type, float_type, nir_rounding_mode_undef); /* Take 1/q but offset mantissa by 1 to correct for rounding. This is * needed for correct results and has been checked exhaustively for @@ -111,7 +111,7 @@ convert_instr_small(nir_builder *b, nir_op op, nir_ssa_def *res = nir_fmul(b, p, rcp); /* Convert back to integer space with rounding inferred by type */ - res = nir_type_convert(b, res, float_type, int_type); + res = nir_type_convert(b, res, float_type, int_type, nir_rounding_mode_undef); /* Get remainder given the quotient */ if (op == nir_op_umod || op == nir_op_imod || op == nir_op_irem)