Module: Mesa
Branch: main
Commit: bf59cfcee1d0cf02971ab74375daf82b0d6b1971
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf59cfcee1d0cf02971ab74375daf82b0d6b1971

Author: Lionel Landwerlin <[email protected]>
Date:   Thu Mar  9 12:12:54 2023 +0200

intel/fs: prevent large vector ops generated by peephole_ffma

Signed-off-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Emma Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21782>

---

 src/intel/compiler/brw_nir.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index b340c09c0b5..6c9feafc478 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -1458,8 +1458,19 @@ brw_postprocess_nir(nir_shader *nir, const struct 
brw_compiler *compiler,
       brw_nir_optimize(nir, compiler, is_scalar);
 
    if (devinfo->ver >= 6) {
-      /* Try and fuse multiply-adds */
-      OPT(brw_nir_opt_peephole_ffma);
+      /* Try and fuse multiply-adds, if successful, run shrink_vectors to
+       * avoid peephole_ffma to generate things like this :
+       *    vec16 ssa_0 = ...
+       *    vec16 ssa_1 = fneg ssa_0
+       *    vec1  ssa_2 = ffma ssa_1, ...
+       *
+       * We want this instead :
+       *    vec16 ssa_0 = ...
+       *    vec1  ssa_1 = fneg ssa_0.x
+       *    vec1  ssa_2 = ffma ssa_1, ...
+       */
+      if (OPT(brw_nir_opt_peephole_ffma))
+         OPT(nir_opt_shrink_vectors);
    }
 
    if (is_scalar)

Reply via email to