diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index 208dd9fd895..6e72b1fbafb 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -26,6 +26,7 @@ #include "util/ralloc.h" #include "nir.h" #include "nir_constant_expressions.h" +#include "nir_search_helpers.h" typedef struct { /* The loop we store information for */ @@ -97,6 +98,10 @@ instr_cost(loop_info_state *state, nir_instr *instr, } else if (nir_op_is_vec_or_mov(alu->op)) { /* movs and vecs are likely free. */ return 0; + } else if ((alu->op == nir_op_fmul || alu->op == nir_op_fmulz) && + is_only_used_by_fadd(alu)) { + /* If we can fuse fma/mad, do not count the mul. */ + return 0; } if (alu->op == nir_op_flrp) {