nir: Don't chase nir_registers

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.

Signed-off-by: Alyssa Rosenzweig <>
226 jobs for !17263 with nir/dont-cahse in 10 seconds (queued for 14 seconds)
latest merge request