[Mesa-dev] [PATCH 3/3] nir: Make remove_phis not remove LCSSA phi's

Thomas Helland thomashelland90 at gmail.com
Tue Jul 28 10:57:51 PDT 2015


Just thought I'd mention that this is a bit RFC.
I was just throwing it out there before dinner so you guys could
have a look at it if you feel like it. I was hoping to put the loop analysis
on here to, but I'll fix it up to use a DFS approach before sending
it out on the list. The way I've solved the DFS here is they way I'm planning
on doing it for the loop analysis too, and in fact a lot of it will be
quite similar.
So if this looks OK-ish then I know I'm on the right track. I'll post the
loop-analysis patches later today when I've reworked them.

2015-07-28 19:52 GMT+02:00 Thomas Helland <thomashelland90 at gmail.com>:
> I was hoping this should fix the problem with the pass
> getting rerun forever, but apparently not. We still need
> a solution like this though, so sending it out for some
> feedback of whether or not this is the way to do it.
>
> Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
> ---
>  src/glsl/nir/nir.h                 | 1 +
>  src/glsl/nir/nir_form_LCSSA.c      | 2 ++
>  src/glsl/nir/nir_opt_remove_phis.c | 3 +++
>  3 files changed, 6 insertions(+)
>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 772fa9a..0abe0cb 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1108,6 +1108,7 @@ typedef struct {
>     struct exec_list srcs; /** < list of nir_phi_src */
>
>     nir_dest dest;
> +   bool is_LCSSA_phi;
>  } nir_phi_instr;
>
>  typedef struct {
> diff --git a/src/glsl/nir/nir_form_LCSSA.c b/src/glsl/nir/nir_form_LCSSA.c
> index 76279f5..b2c0c1f 100644
> --- a/src/glsl/nir/nir_form_LCSSA.c
> +++ b/src/glsl/nir/nir_form_LCSSA.c
> @@ -82,6 +82,8 @@ insert_phi_for_def(nir_ssa_def *def_in_loop, nir_src *use_outside_loop,
>  {
>     nir_phi_instr *phi = nir_phi_instr_create(state->shader);
>
> +   phi->is_LCSSA_phi = true;
> +
>     nir_block *succ = nir_cf_node_as_block(
>                          nir_cf_node_next(&state->loop->cf_node));
>
> diff --git a/src/glsl/nir/nir_opt_remove_phis.c b/src/glsl/nir/nir_opt_remove_phis.c
> index 7896584..e4fc70a 100644
> --- a/src/glsl/nir/nir_opt_remove_phis.c
> +++ b/src/glsl/nir/nir_opt_remove_phis.c
> @@ -55,6 +55,9 @@ remove_phis_block(nir_block *block, void *state)
>
>        nir_phi_instr *phi = nir_instr_as_phi(instr);
>
> +      if (phi->is_LCSSA_phi)
> +         break;
> +
>        nir_ssa_def *def = NULL;
>        bool srcs_same = true;
>
> --
> 2.4.6
>


More information about the mesa-dev mailing list