Skip to content

Draft: nir: Don't chase nir_registers

Alyssa Rosenzweig requested to merge alyssa/mesa:nir/dont-cahse into main

Trying to use nir_ssa_scalar on a shader that's gone out-of-SSA is risky. If there's a nir_register accessed anywhere in the expression tree, trying to chase moves at the root causes an assertion failure:

test_basic: ../src/compiler/nir/nir.c:2930: nir_alu_instr_is_copy: Assertion `instr->src[0].src.is_ssa' failed.

In case we hit a nir_register, stop chasing further (indeed, it would be invalid to do so.) Go as far as we can and stop.

This makes nir_ssa_scalar safe to use in instruction selection for backends that use nir_from_ssa (most of them).

Fixes test_basic.kernel_preprocessor_macros on Valhall.


Draft because I don't know if this is the right fix. Smells like a hack.

Merge request reports