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

Thomas Helland thomashelland90 at gmail.com
Tue Jul 28 10:52:44 PDT 2015


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