diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c index 3b85ba8f736..1670f564ec6 100644 --- a/src/compiler/nir/nir_lower_double_ops.c +++ b/src/compiler/nir/nir_lower_double_ops.c @@ -654,6 +654,7 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr, name = "__fmul64"; mangled_name = "__fmul64(u641;u641;"; break; + case nir_op_fmad: case nir_op_ffma_old: name = "__fmad64"; mangled_name = "__fmad64(u641;u641;u641;"; diff --git a/src/compiler/nir/nir_lower_floats.c b/src/compiler/nir/nir_lower_floats.c index 82a283a64a0..e1851eab220 100644 --- a/src/compiler/nir/nir_lower_floats.c +++ b/src/compiler/nir/nir_lower_floats.c @@ -74,6 +74,7 @@ lower_float_instr_to_soft(nir_builder *b, nir_instr *instr, case nir_op_fmul: mangled_name = "__fmul32(u1;u1;"; break; + case nir_op_fmad: case nir_op_ffma_old: mangled_name = "__fmad32(u1;u1;u1;"; break; diff --git a/src/compiler/nir/nir_opt_fp_math_ctrl.c b/src/compiler/nir/nir_opt_fp_math_ctrl.c index 96533f5f3e6..04e7b4d26b8 100644 --- a/src/compiler/nir/nir_opt_fp_math_ctrl.c +++ b/src/compiler/nir/nir_opt_fp_math_ctrl.c @@ -175,9 +175,14 @@ opt_alu_fp_math_ctrl(nir_alu_instr *alu, struct opt_fp_ctrl_state *state) break; } + case nir_op_ffmaz: + case nir_op_fmadz: case nir_op_ffmaz_old: src_mark_preserve_sz(&alu->src[2].src, NULL); break; + case nir_op_ffma: + case nir_op_ffma_weak: + case nir_op_fmad: case nir_op_ffma_old: if ((nir_analyze_fp_class(&state->fp_class_state, alu->src[2].src.ssa) & FP_CLASS_NEG_ZERO) && !nir_alu_srcs_equal(alu, alu, 0, 1)) { diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c index 33eee0f77cd..d381cf2bed0 100644 --- a/src/compiler/nir/nir_opt_undef.c +++ b/src/compiler/nir/nir_opt_undef.c @@ -222,7 +222,7 @@ visit_undef_use(nir_src *src, struct visit_info *info) info->replace_undef_with_constant = true; if (nir_op_infos[alu->op].input_types[i] & nir_type_float && alu->op != nir_op_fmulz && - (alu->op != nir_op_ffmaz_old || i == 2) && + (nir_alu_instr_is_mul_add_z(alu) || i == 2) && alu->op != nir_op_pack_half_2x16_rtz_split) info->prefer_nan = true; } diff --git a/src/compiler/nir/nir_opt_varyings.c b/src/compiler/nir/nir_opt_varyings.c index 9d6f0a679fd..19954900c03 100644 --- a/src/compiler/nir/nir_opt_varyings.c +++ b/src/compiler/nir/nir_opt_varyings.c @@ -3253,7 +3253,7 @@ find_tes_triangle_interp_1fmul_2ffma(struct linkage_info *linkage, unsigned i) /* Reject exact ops because we are going to do an inexact transformation * with it. */ - if (!alu || (alu->op != nir_op_fmul && alu->op != nir_op_ffma_old) || + if (!alu || (alu->op != nir_op_fmul && !nir_alu_instr_is_mul_add(alu)) || nir_alu_instr_is_exact(alu) || !gather_fmul_tess_coord(iter->instr, alu, vertex_index, &tess_coord_swizzle, &tess_coord_used, @@ -3263,7 +3263,7 @@ find_tes_triangle_interp_1fmul_2ffma(struct linkage_info *linkage, unsigned i) /* The multiplication must only be used by ffma. */ if (alu->op == nir_op_fmul) { nir_alu_instr *ffma = get_single_use_as_alu(&alu->def); - if (!ffma || ffma->op != nir_op_ffma_old) + if (!nir_alu_instr_is_mul_add(ffma)) return false; if (num_fmuls == 1) @@ -3388,6 +3388,11 @@ can_move_alu_across_interp(struct linkage_info *linkage, nir_alu_instr *alu) */ case nir_op_fmul: case nir_op_fmulz: + case nir_op_ffma: + case nir_op_ffma_weak: + case nir_op_ffmaz: + case nir_op_fmad: + case nir_op_fmadz: case nir_op_ffma_old: case nir_op_ffmaz_old: return GET_SRC_INTERP(alu, 0) == FLAG_INTERP_CONVERGENT || diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index 1ac17c81698..c88a6554b6a 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -838,6 +838,11 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 return; case nir_op_ffma_old: case nir_op_ffmaz_old: + case nir_op_ffma: + case nir_op_ffma_weak: + case nir_op_ffmaz: + case nir_op_fmad: + case nir_op_fmadz: case nir_op_flrp: push_fp_query(state, alu->src[0].src.ssa); push_fp_query(state, alu->src[1].src.ssa); @@ -1320,9 +1325,13 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 break; } + case nir_op_fmad: + case nir_op_fmadz: + case nir_op_ffma: case nir_op_ffma_old: + case nir_op_ffmaz: case nir_op_ffmaz_old: { - bool mulz = alu->op == nir_op_ffmaz_old; + bool mulz = nir_alu_instr_is_mul_add_z(alu); bool src_eq = nir_alu_srcs_equal(alu, alu, 0, 1); bool src_neg_eq = !nir_src_is_const(alu->src[0].src) && nir_alu_srcs_negative_equal(alu, alu, 0, 1); fp_class_mask r_mul = fmul_fp_class(src_res[0], src_res[1], mulz, src_eq, src_neg_eq);