On Wed, Jan 28, 2015 at 4:28 PM, Ian Romanick <i...@freedesktop.org> wrote:
> On 01/27/2015 05:31 PM, Jason Ekstrand wrote: > > v2 Jason Ekstrand <jason.ekstr...@intel.com>: > > - Add better comments > > - Use nir_ssa_dest_init and nir_src_for_ssa more places > > - Fix some void * casts > > > > v3 Jason Ekstrand <jason.ekstr...@intel.com>: > > - Rework the way we determine whether or not to sccalarize a phi node to > > make the recursion non-bogus > > - Treat load_const instructions as scalarizable > > --- > > src/glsl/Makefile.sources | 1 + > > src/glsl/nir/nir.h | 2 + > > src/glsl/nir/nir_lower_phis_to_scalar.c | 266 > ++++++++++++++++++++++++++++++++ > > 3 files changed, 269 insertions(+) > > create mode 100644 src/glsl/nir/nir_lower_phis_to_scalar.c > > > > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources > > index face22e..bf6b70b 100644 > > --- a/src/glsl/Makefile.sources > > +++ b/src/glsl/Makefile.sources > > @@ -31,6 +31,7 @@ NIR_FILES = \ > > nir/nir_lower_global_vars_to_local.c \ > > nir/nir_lower_locals_to_regs.c \ > > nir/nir_lower_io.c \ > > + nir/nir_lower_phis_to_scalar.c \ > > nir/nir_lower_samplers.cpp \ > > nir/nir_lower_system_values.c \ > > nir/nir_lower_to_source_mods.c \ > > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h > > index 980fdd0..4f58eee 100644 > > --- a/src/glsl/nir/nir.h > > +++ b/src/glsl/nir/nir.h > > @@ -1526,6 +1526,8 @@ void nir_remove_dead_variables(nir_shader *shader); > > void nir_lower_vec_to_movs(nir_shader *shader); > > void nir_lower_alu_to_scalar(nir_shader *shader); > > > > +void nir_lower_phis_to_scalar(nir_shader *shader); > > + > > void nir_lower_samplers(nir_shader *shader, > > struct gl_shader_program *shader_program, > > struct gl_program *prog); > > diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c > b/src/glsl/nir/nir_lower_phis_to_scalar.c > > new file mode 100644 > > index 0000000..a94b8b0 > > --- /dev/null > > +++ b/src/glsl/nir/nir_lower_phis_to_scalar.c > > @@ -0,0 +1,266 @@ > > +/* > > + * Copyright © 2015 Intel Corporation > > + * > > + * Permission is hereby granted, free of charge, to any person > obtaining a > > + * copy of this software and associated documentation files (the > "Software"), > > + * to deal in the Software without restriction, including without > limitation > > + * the rights to use, copy, modify, merge, publish, distribute, > sublicense, > > + * and/or sell copies of the Software, and to permit persons to whom the > > + * Software is furnished to do so, subject to the following conditions: > > + * > > + * The above copyright notice and this permission notice (including the > next > > + * paragraph) shall be included in all copies or substantial portions > of the > > + * Software. > > + * > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > EXPRESS OR > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT > SHALL > > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR > OTHER > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > ARISING > > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > DEALINGS > > + * IN THE SOFTWARE. > > + * > > + * Authors: > > + * Jason Ekstrand (ja...@jlekstrand.net) > > + * > > + */ > > + > > +#include "nir.h" > > + > > +/* > > + * Implements a pass that lowers vector phi nodes to scalar phi nodes > when > > + * we don't think it will hurt anything. > > + */ > > + > > +struct lower_phis_to_scalar_state { > > + void *mem_ctx; > > + void *dead_ctx; > > + > > + /* Hash table marking which phi nodes are scalarizable. The key is > > + * pointers to phi instructions and the entry is either NULL for not > > + * scalarizable or non-null for scalarizable. > > + */ > > + struct hash_table *phi_table; > > +}; > > + > > +static bool > > +should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state > *state); > > + > > +static bool > > +is_phi_src_scalarizable(nir_phi_src *src, > > + struct lower_phis_to_scalar_state *state) > > +{ > > + /* Don't know what to do with non-ssa sources */ > > + if (!src->src.is_ssa) > > + return false; > > + > > + nir_instr *src_instr = src->src.ssa->parent_instr; > > + switch (src_instr->type) { > > + case nir_instr_type_alu: { > > + nir_alu_instr *src_alu = nir_instr_as_alu(src_instr); > > + > > + /* ALU operations with output_size == 0 should be scalarized. We > > + * will also see a bunch of vecN operations from scalarizing ALU > > + * operations and, since they can easily be copy-propagated, they > > + * are ok too. > > + */ > > + return nir_op_infos[src_alu->op].output_size == 0 || > > + src_alu->op != nir_op_vec2 || > > + src_alu->op != nir_op_vec3 || > > + src_alu->op != nir_op_vec4; > > I don't think this logic is correct. It will return true if src_alu->op > is nir_op_vec2 because that's not nir_op_vec4. Right? > > Bah! Yeah, that's completely bogus. That said, I don't think you're looking at the latest version.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev