[Mesa-dev] [PATCH 1/2] nir: Teach src_is_type about nir_instr_type_load_const
Ilia Mirkin
imirkin at alum.mit.edu
Fri Jul 20 00:44:35 UTC 2018
On Thu, Jul 19, 2018 at 8:39 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> ---
> After looking back at Tim's patches, I realized that I had done my
> implementation slightly differntly. I didn't include these in my branch
> because it caused a bunch of regressions on i965. I'm just sending
> these out in case we end up going this route...
>
>
> src/compiler/nir/nir_search.c | 28 ++++++++++++++++++++++++----
> 1 file changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
> index 28b36b2b863..c727e9c70b7 100644
> --- a/src/compiler/nir/nir_search.c
> +++ b/src/compiler/nir/nir_search.c
> @@ -49,7 +49,8 @@ static const uint8_t identity_swizzle[] = { 0, 1, 2, 3 };
> * Used for satisfying 'a at type' constraints.
> */
> static bool
> -src_is_type(nir_src src, nir_alu_type type)
> +src_is_type(nir_src src, nir_alu_type type, unsigned num_components,
> + const uint8_t *swizzle)
> {
> assert(type != nir_type_invalid);
>
> @@ -69,10 +70,14 @@ src_is_type(nir_src src, nir_alu_type type)
> case nir_op_iand:
> case nir_op_ior:
> case nir_op_ixor:
> - return src_is_type(src_alu->src[0].src, nir_type_bool) &&
> - src_is_type(src_alu->src[1].src, nir_type_bool);
> + return src_is_type(src_alu->src[0].src, nir_type_bool,
> + num_components, swizzle) &&
> + src_is_type(src_alu->src[1].src, nir_type_bool,
> + num_components, swizzle);
> case nir_op_inot:
> return src_is_type(src_alu->src[0].src, nir_type_bool);
Was there supposed to be a - here? I don't think this will compile as-is.
> + return src_is_type(src_alu->src[0].src, nir_type_bool,
> + num_components, swizzle);
> default:
> break;
> }
> @@ -86,6 +91,20 @@ src_is_type(nir_src src, nir_alu_type type)
> return intr->intrinsic == nir_intrinsic_load_front_face ||
> intr->intrinsic == nir_intrinsic_load_helper_invocation;
> }
> + } else if (src.ssa->parent_instr->type == nir_instr_type_load_const) {
> + if (type == nir_type_bool) {
> + const nir_const_value *const val = nir_src_as_const_value(src);
> +
> + assert(val != NULL);
> +
> + for (unsigned i = 0; i < num_components; i++) {
> + if (val->u32[swizzle[i]] != NIR_FALSE &&
> + val->u32[swizzle[i]] != NIR_TRUE)
> + return false;
> + }
> +
> + return true;
> + }
> }
>
> /* don't know */
> @@ -159,7 +178,8 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
> return false;
>
> if (var->type != nir_type_invalid &&
> - !src_is_type(instr->src[src].src, var->type))
> + !src_is_type(instr->src[src].src, var->type, num_components,
> + new_swizzle))
> return false;
>
> state->variables_seen |= (1 << var->variable);
> --
> 2.14.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list