gallium/ttn: don't upset nir_validate w/ BRK's
authorRob Clark <robclark@freedesktop.org>
Fri, 26 Jun 2015 18:24:08 +0000 (14:24 -0400)
committerRob Clark <robclark@freedesktop.org>
Tue, 30 Jun 2015 16:13:44 +0000 (12:13 -0400)
Previously we were unconditionally doing ttn_get_src() even for
instructions with no src's.  Which created a lot of unnecessary
load_const instructions.  These were mostly harmless since NIR opt
passes would strip them back out.  But for an ENDIF following a
BRK, it would result in load_const instructions created after the
NIR break instruction.  Which nir_validate dislikes.

But we can actually just dtrt by using NumSrcRegs instead.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/auxiliary/nir/tgsi_to_nir.c

index bd4cdcbbfcf5bfa49c81860b65f7566c338ebfb8..e1647d53a40c8f2de7700a989f140095c6a2819c 100644 (file)
@@ -1491,7 +1491,7 @@ ttn_emit_instruction(struct ttn_compile *c)
       return;
 
    nir_ssa_def *src[TGSI_FULL_MAX_SRC_REGISTERS];
-   for (i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++) {
+   for (i = 0; i < tgsi_inst->Instruction.NumSrcRegs; i++) {
       src[i] = ttn_get_src(c, &tgsi_inst->Src[i]);
    }
    nir_alu_dest dest = ttn_get_dest(c, tgsi_dst);