[Mesa-dev] [PATCH] nir: Turn imov/fmov of undef into undef

Jason Ekstrand jason at jlekstrand.net
Fri Dec 16 06:20:02 UTC 2016


On Dec 15, 2016 4:26 PM, "Kenneth Graunke" <kenneth at whitecape.org> wrote:

On Friday, December 16, 2016 10:17:33 AM PST Timothy Arceri wrote:
> Reverting the previous attempt at this a5502a721fd30fd resulted in
> the following Vulkan test failing.
>
> dEQP-VK.glsl.return.return_in_dynamic_loop_dynamic_vertex
>
> This time we use the num_components from the alu dest rather than
> num_inputs to the op to determine the size of the undef.
>
> Cc: "13.0" <mesa-stable at lists.freedesktop.org>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99100
> ---
>  src/compiler/nir/nir_opt_undef.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_
undef.c
> index c4777a8..8d3210c 100644
> --- a/src/compiler/nir/nir_opt_undef.c
> +++ b/src/compiler/nir/nir_opt_undef.c
> @@ -79,22 +79,22 @@ opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
>  {
>     if (alu->op != nir_op_vec2 &&
>         alu->op != nir_op_vec3 &&
> -       alu->op != nir_op_vec4)
> +       alu->op != nir_op_vec4 &&
> +       alu->op != nir_op_fmov &&
> +       alu->op != nir_op_imov)
>        return false;
>
>     assert(alu->dest.dest.is_ssa);
>
> -   unsigned num_components = nir_op_infos[alu->op].num_inputs;
> -
> -   for (unsigned i = 0; i < num_components; i++) {
> +   for (unsigned i = 0; i < nir_op_infos[alu->op].num_inputs; i++) {
>        if (!alu->src[i].src.is_ssa ||
>            alu->src[i].src.ssa->parent_instr->type !=
nir_instr_type_ssa_undef)
>           return false;
>     }
>
>     b->cursor = nir_before_instr(&alu->instr);
> -   nir_ssa_def *undef =
> -      nir_ssa_undef(b, num_components, nir_dest_bit_size(alu->dest.
dest));
> +   nir_ssa_def *undef = nir_ssa_undef(b, alu->dest.dest.ssa.num_
components,
> +                                      nir_dest_bit_size(alu->dest.dest));
>     nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(undef));
>
>     return true;
>

I don't understand why that test regressed...I suspect this is just
hiding an actual bug.


Agreed.  We should probably look into that.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

  But the optimization looks right to me, so

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161215/7b635168/attachment.html>


More information about the mesa-dev mailing list