diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-05-07 02:03:59 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-05-29 08:19:15 -0700 |
commit | 8bdf5a008b3e22f0cd2e836184decfac3265f0df (patch) | |
tree | c1598e7c929b02e919c39deded40d07d0dcb76a1 /src/compiler/nir/nir_validate.c | |
parent | ee2a92bcde0d34f5f92375598167422206efda21 (diff) |
nir: Allow derefs to be used as phi sources
It is possible and valid for a pointer to be selected based on a
conditional before used, and depending on the mode, those cases will
result in a phi with derefs as sources.
To achieve this, we don't rematerialize derefs that are used by phis.
As a consequence, when converting from SSA to regs, we may have phis
that come from different blocks and are used by phis. We now convert
those to regs too.
Validation was added to ensure only derefs of certain modes can be
used as phi sources. No extra validation is needed for the presence
of cast, any instruction that uses derefs will validate the
deref-chain is complete (ending in a cast or a var).
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_validate.c')
-rw-r--r-- | src/compiler/nir/nir_validate.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index bf3f23f2547..682ed762f57 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -499,6 +499,15 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state) * NULL, an explicit comparison operation should be used. */ validate_assert(state, list_empty(&instr->dest.ssa.if_uses)); + + /* Only certain modes can be used as sources for phi instructions. */ + nir_foreach_use(use, &instr->dest.ssa) { + if (use->parent_instr->type == nir_instr_type_phi) { + validate_assert(state, instr->mode == nir_var_mem_ubo || + instr->mode == nir_var_mem_ssbo || + instr->mode == nir_var_mem_shared); + } + } } static void |