[Mesa-dev] [PATCH v2 23/23] nir: verify destination bit size when checking algebraic optimizations

Jason Ekstrand jason at jlekstrand.net
Fri Apr 1 19:35:57 UTC 2016


Unless I'm missing something, this series doesn't contain anything that
uses this patch.  Let's drop it for now and put it in with whatever adds
the actual nir_opt_algebraic changes.

Another option would be to silently bail if nir_search tries to create an
expression where the opcode has an explicit bit size and it doesn't match
the bit size that it needs.  I'm not sure what the best thing to do is.
I'll think on it.

On Thu, Mar 31, 2016 at 3:00 AM, Samuel Iglesias Gonsálvez <
siglesias at igalia.com> wrote:

> Some instructions (like flrp in i965) cannot be lowered depending on the
> bit size because it doesn't support all bit sizes.
>
> If the bit size field is defined in nir_opt_algebraic.py, take it into
> account.
>
> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> ---
>  src/compiler/nir/nir_algebraic.py | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/nir/nir_algebraic.py
> b/src/compiler/nir/nir_algebraic.py
> index d05564f..9c679ac 100644
> --- a/src/compiler/nir/nir_algebraic.py
> +++ b/src/compiler/nir/nir_algebraic.py
> @@ -180,6 +180,11 @@ class SearchAndReplace(object):
>        else:
>           self.condition = 'true'
>
> +      if len(transform) > 3:
> +         self.bit_size = transform[3]
> +      else:
> +         self.bit_size = 0
> +
>        if self.condition not in condition_list:
>           condition_list.append(self.condition)
>        self.condition_index = condition_list.index(self.condition)
> @@ -208,6 +213,7 @@ struct transform {
>     const nir_search_expression *search;
>     const nir_search_value *replace;
>     unsigned condition_offset;
> +   unsigned bit_size;
>  };
>
>  struct opt_state {
> @@ -226,7 +232,7 @@ struct opt_state {
>
>  static const struct transform ${pass_name}_${opcode}_xforms[] = {
>  % for xform in xform_list:
> -   { &${xform.search.name}, ${xform.replace.c_ptr},
> ${xform.condition_index} },
> +   { &${xform.search.name}, ${xform.replace.c_ptr},
> ${xform.condition_index}, ${xform.bit_size}},
>  % endfor
>  };
>  % endfor
> @@ -249,6 +255,9 @@ ${pass_name}_block(nir_block *block, void *void_state)
>        case nir_op_${opcode}:
>           for (unsigned i = 0; i <
> ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
>              const struct transform *xform =
> &${pass_name}_${opcode}_xforms[i];
> +            if (xform->bit_size != 0 &&
> +                alu->dest.dest.ssa.bit_size != xform->bit_size)
> +               continue;
>              if (state->condition_flags[xform->condition_offset] &&
>                  nir_replace_instr(alu, xform->search, xform->replace,
>                                    state->mem_ctx)) {
> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160401/d98f504c/attachment.html>


More information about the mesa-dev mailing list