[Mesa-dev] [PATCH] intel: compiler: remove dead local variables at optimization pass

Lionel Landwerlin lionel.g.landwerlin at intel.com
Thu Aug 23 13:37:22 UTC 2018

We're hitting an assert in gfxbench because one of the local variable
is a sampler (according to Jason this isn't valid) :

testfw_app: ../src/compiler/nir_types.cpp:551: void glsl_get_natural_size_align_bytes(const glsl_type*, unsigned int*, unsigned int*): Assertion `!"type does not have a natural size"' failed.

Since this particular variable isn't used and it can be eliminated by
removing unused local variables in the optimization pass. This makes
sense also for valid local variables.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
 src/intel/compiler/brw_nir.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index 29ad68fdb2a..ede341c8f3a 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -586,6 +586,7 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,
                              nir_lower_dround_even |
+      OPT(nir_remove_dead_variables, nir_var_local);
    } while (progress);
    return nir;

More information about the mesa-dev mailing list