[Mesa-dev] [PATCH 2/4] nir: turn ssa check into an assert
Ian Romanick
idr at freedesktop.org
Wed Feb 13 22:41:27 UTC 2019
On 2/13/19 12:00 AM, Timothy Arceri wrote:
> Everthing should be in ssa form when this is called. Checking
> for it here is expensive so turn this into an assert instead.
>
> Do the cheap thing first and check if we can even progress with
> this instruction type.
> ---
> src/compiler/nir/nir_instr_set.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
> index 61476c0b03f..c795efbca6a 100644
> --- a/src/compiler/nir/nir_instr_set.c
> +++ b/src/compiler/nir/nir_instr_set.c
> @@ -498,6 +498,16 @@ dest_is_ssa(nir_dest *dest, void *data)
> return dest->is_ssa;
> }
>
> +static bool
> +instr_each_src_and_dest_is_ssa(nir_instr *instr)
> +{
> + if (!nir_foreach_dest(instr, dest_is_ssa, NULL) ||
> + !nir_foreach_src(instr, src_is_ssa, NULL))
> + return false;
> +
> + return true;
I get that this is trying to be obvious about just moving code, but I'd
like this a lot better if it more directly matched the name:
return nir_foreach_dest(instr, dest_is_ssa, NULL) &&
nir_foreach_src(instr, src_is_ssa, NULL);
> +}
> +
> /* This function determines if uses of an instruction can safely be rewritten
> * to use another identical instruction instead. Note that this function must
> * be kept in sync with hash_instr() and nir_instrs_equal() -- only
> @@ -509,9 +519,7 @@ static bool
> instr_can_rewrite(nir_instr *instr)
> {
> /* We only handle SSA. */
> - if (!nir_foreach_dest(instr, dest_is_ssa, NULL) ||
> - !nir_foreach_src(instr, src_is_ssa, NULL))
> - return false;
> + assert(instr_each_src_and_dest_is_ssa(instr));
>
> switch (instr->type) {
> case nir_instr_type_alu:
More information about the mesa-dev
mailing list