diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index f898f708cfa..4000d2579d3 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2589,10 +2589,10 @@ late_optimizations = [ # re-combine inexact mul+add to ffma. Do this before fsub so that a * b - c # gets combined to fma(a, b, -c). - (('~fadd@16', ('fmul', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma16'), - (('~fadd@32', ('fmul', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma32'), - (('~fadd@64', ('fmul', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma64'), - (('~fadd@32', ('fmulz', a, b), c), ('ffmaz', a, b, c), 'options->fuse_ffma32'), + (('~fadd@16', ('fmul(is_only_used_by_fadd)', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma16'), + (('~fadd@32', ('fmul(is_only_used_by_fadd)', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma32'), + (('~fadd@64', ('fmul(is_only_used_by_fadd)', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma64'), + (('~fadd@32', ('fmulz(is_only_used_by_fadd)', a, b), c), ('ffmaz', a, b, c), 'options->fuse_ffma32'), # Subtractions get lowered during optimization, so we need to recombine them (('fadd@8', a, ('fneg', 'b')), ('fsub', 'a', 'b'), 'options->has_fsub'), diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h index 60a349baca0..da1e9b506a8 100644 --- a/src/compiler/nir/nir_search_helpers.h +++ b/src/compiler/nir/nir_search_helpers.h @@ -422,6 +422,24 @@ is_only_used_as_float(const nir_alu_instr *instr) return true; } +static inline bool +is_only_used_by_fadd(const nir_alu_instr *instr) +{ + nir_foreach_use(src, &instr->dest.dest.ssa) { + const nir_instr *const user_instr = src->parent_instr; + if (user_instr->type != nir_instr_type_alu) + return false; + + const nir_alu_instr *const user_alu = nir_instr_as_alu(user_instr); + assert(instr != user_alu); + + if (user_alu->op != nir_op_fadd) + return false; + } + + return true; +} + static inline bool only_lower_8_bits_used(const nir_alu_instr *instr) { diff --git a/src/gallium/drivers/virgl/ci/traces-virgl-iris.yml b/src/gallium/drivers/virgl/ci/traces-virgl-iris.yml index aa6d45a28b1..f60134d1f56 100644 --- a/src/gallium/drivers/virgl/ci/traces-virgl-iris.yml +++ b/src/gallium/drivers/virgl/ci/traces-virgl-iris.yml @@ -21,7 +21,7 @@ traces: checksum: c377f21f7bfaca0c04983612e7c9a7bb gputest/pixmark-piano-v2.trace: gl-virgl: - checksum: a4f3552e26c31a6d143519ee7ad47eea + checksum: 495ae47d50672d095854765bdb2eedc5 gputest/triangle-v2.trace: gl-virgl: checksum: 5f694874b15bcd7a3689b387c143590b @@ -30,7 +30,7 @@ traces: checksum: 32e8b627a33ad08d416dfdb804920371 0ad/0ad-v2.trace: gl-virgl: - checksum: 784d20f0166ef66b4b65f25f2858a5ee + checksum: 78007615359981f7035f26c5b7759229 glmark2/buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=false-v2.trace: gl-virgl: checksum: 040232e01e394a967dc3320bb9252870 @@ -126,7 +126,7 @@ traces: label: [crash] gputest/pixmark-julia-fp32-v2.trace: gl-virgl: - checksum: fbf5e44a6f46684b84e5bb5ad6d36c67 + checksum: 0aa3a82a5b849cb83436e52c4e3e95ac gputest/pixmark-julia-fp64-v2.trace: gl-virgl: checksum: 1760aea00af985b8cd902128235b08f6 diff --git a/src/gallium/drivers/virgl/ci/traces-virgl.yml b/src/gallium/drivers/virgl/ci/traces-virgl.yml index 8f288d59812..7da834d4f83 100644 --- a/src/gallium/drivers/virgl/ci/traces-virgl.yml +++ b/src/gallium/drivers/virgl/ci/traces-virgl.yml @@ -123,7 +123,7 @@ traces: label: [crash] gputest/pixmark-julia-fp32-v2.trace: gl-virgl: - checksum: 8b3584b1dd8f1d1bb63205564bd78e4e + checksum: 25f938c726c68c08a88193f28f7c4474 gputest/pixmark-julia-fp64-v2.trace: gl-virgl: checksum: 73ccaff82ea764057fb0f93f0024cf84 @@ -159,7 +159,7 @@ traces: checksum: 37780a6eaa38a55700e8207e89009f56 neverball/neverball-v2.trace: gl-virgl: - checksum: cc11743f008ccd76adf72695a423436a + checksum: 0b8ae7dd4f7f26c3278ded8a5694b983 pathfinder/canvas_moire-v2.trace: gl-virgl: checksum: 25ba8f18274126670311bd3ffe058f74