broadcom/compiler: Add a constant folding pass after nir_lower_io
authorArcady Goldmints-Orlov <agoldmints@igalia.com>
Sat, 25 Jul 2020 15:39:31 +0000 (10:39 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 20 Aug 2020 20:14:14 +0000 (20:14 +0000)
The nir_lower_io pass produces a bunch of constant arithmetic, and
assumes that constant folding will simplify it away.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6356>

src/broadcom/compiler/vir.c

index d81931ec27bb127c0060a22408481cebd77a2b1c..d06f789161fab09e4589e14889d24c16702b86c5 100644 (file)
@@ -821,8 +821,11 @@ v3d_nir_lower_vs_early(struct v3d_compile *c)
         NIR_PASS_V(c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
                    type_size_vec4,
                    (nir_lower_io_options)0);
-        /* clean up nir_lower_io's deref_var remains */
+        /* clean up nir_lower_io's deref_var remains and do a constant folding pass
+         * on the code it generated.
+         */
         NIR_PASS_V(c->s, nir_opt_dce);
+        NIR_PASS_V(c->s, nir_opt_constant_folding);
 }
 
 static void