brw/nir: Use nir_opt_reassociate_matrix_mul

This needs to be called before intel_nir_opt_peephole_ffma, so I
arbitrarilly decided to call it right before.

All Intel platforms had similar results. (Lunar Lake shown)
total instructions in shared programs: 17120227 -> 17118227 (-0.01%)
instructions in affected programs: 5854 -> 3854 (-34.16%)
helped: 51 / HURT: 0

total cycles in shared programs: 895497762 -> 894733940 (-0.09%)
cycles in affected programs: 4603518 -> 3839696 (-16.59%)
helped: 95 / HURT: 21

LOST:   1
GAINED: 0

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35925>
This commit is contained in:
Ian Romanick
2025-07-02 19:37:25 -07:00
committed by Marge Bot
parent 69afd8678a
commit 5adab50283
+6
View File
@@ -2068,6 +2068,12 @@ brw_postprocess_nir(nir_shader *nir, const struct brw_compiler *compiler,
if (OPT(nir_lower_int64))
brw_nir_optimize(nir, devinfo);
/* This pass specifically looks for sequences of fmul and fadd that
* intel_nir_opt_peephole_ffma will try to eliminate. Call this
* reassociation pass first.
*/
OPT(nir_opt_reassociate_matrix_mul);
/* Try and fuse multiply-adds, if successful, run shrink_vectors to
* avoid peephole_ffma to generate things like this :
* vec16 ssa_0 = ...