[038.1/129] FIXUP: nir: Support deref instructions in opt_undef

Submitted by Bas Nieuwenhuizen on June 3, 2018, 11:10 p.m.

Details

Message ID 20180603231012.119411-3-bas@basnieuwenhuizen.nl
State New
Headers show

Not browsing as part of any series.

Patch hide | download patch | download mbox

diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c
index 1439ca9c165..e42a9af2bdf 100644
--- a/src/compiler/nir/nir_opt_undef.c
+++ b/src/compiler/nir/nir_opt_undef.c
@@ -107,20 +107,24 @@  opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
 static bool
 opt_undef_store(nir_intrinsic_instr *intrin)
 {
+   int arg_index;
    switch (intrin->intrinsic) {
    case nir_intrinsic_store_deref:
+      arg_index = 1;
+      break;
    case nir_intrinsic_store_var:
    case nir_intrinsic_store_output:
    case nir_intrinsic_store_per_vertex_output:
    case nir_intrinsic_store_ssbo:
    case nir_intrinsic_store_shared:
+      arg_index =  0;
       break;
    default:
       return false;
    }
 
-   if (!intrin->src[0].is_ssa ||
-       intrin->src[0].ssa->parent_instr->type != nir_instr_type_ssa_undef)
+   if (!intrin->src[arg_index].is_ssa ||
+       intrin->src[arg_index].ssa->parent_instr->type != nir_instr_type_ssa_undef)
       return false;
 
    nir_instr_remove(&intrin->instr);

Comments

LGTM

On Sun, Jun 3, 2018 at 4:10 PM, Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
wrote:

> ---
>  src/compiler/nir/nir_opt_undef.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_
> undef.c
> index 1439ca9c165..e42a9af2bdf 100644
> --- a/src/compiler/nir/nir_opt_undef.c
> +++ b/src/compiler/nir/nir_opt_undef.c
> @@ -107,20 +107,24 @@ opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
>  static bool
>  opt_undef_store(nir_intrinsic_instr *intrin)
>  {
> +   int arg_index;
>     switch (intrin->intrinsic) {
>     case nir_intrinsic_store_deref:
> +      arg_index = 1;
> +      break;
>     case nir_intrinsic_store_var:
>     case nir_intrinsic_store_output:
>     case nir_intrinsic_store_per_vertex_output:
>     case nir_intrinsic_store_ssbo:
>     case nir_intrinsic_store_shared:
> +      arg_index =  0;
>        break;
>     default:
>        return false;
>     }
>
> -   if (!intrin->src[0].is_ssa ||
> -       intrin->src[0].ssa->parent_instr->type !=
> nir_instr_type_ssa_undef)
> +   if (!intrin->src[arg_index].is_ssa ||
> +       intrin->src[arg_index].ssa->parent_instr->type !=
> nir_instr_type_ssa_undef)
>        return false;
>
>     nir_instr_remove(&intrin->instr);
> --
> 2.17.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>