On Wed, Oct 14, 2015 at 11:30 AM, Matt Turner <matts...@gmail.com> wrote: > Make them members of fs_inst/vec4_instruction for use elsewhere. > > Also fix the fs version to check that dst.type == src[1].type and for > !saturate.
Reviewed-by: Jason Ekstrand <jason.ekstr...@intel.com> > --- > src/mesa/drivers/dri/i965/brw_fs.cpp | 12 ++++++++++++ > src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 15 ++------------- > src/mesa/drivers/dri/i965/brw_ir_fs.h | 1 + > src/mesa/drivers/dri/i965/brw_ir_vec4.h | 1 + > src/mesa/drivers/dri/i965/brw_vec4.cpp | 12 ++++++++++++ > src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp | 16 ++-------------- > 6 files changed, 30 insertions(+), 27 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp > b/src/mesa/drivers/dri/i965/brw_fs.cpp > index d000f16..3837bbc 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -338,6 +338,18 @@ fs_inst::can_do_source_mods(const struct brw_device_info > *devinfo) > } > > bool > +fs_inst::can_change_types() const > +{ > + return dst.type == src[0].type && > + !src[0].abs && !src[0].negate && !saturate && > + (opcode == BRW_OPCODE_MOV || > + (opcode == BRW_OPCODE_SEL && > + dst.type == src[1].type && > + predicate != BRW_PREDICATE_NONE && > + !src[1].abs && !src[1].negate)); > +} > + > +bool > fs_inst::has_side_effects() const > { > return this->eot || backend_instruction::has_side_effects(); > diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > index 230b0ca..5589716 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > @@ -275,17 +275,6 @@ is_logic_op(enum opcode opcode) > opcode == BRW_OPCODE_NOT); > } > > -static bool > -can_change_source_types(fs_inst *inst) > -{ > - return !inst->src[0].abs && !inst->src[0].negate && > - inst->dst.type == inst->src[0].type && > - (inst->opcode == BRW_OPCODE_MOV || > - (inst->opcode == BRW_OPCODE_SEL && > - inst->predicate != BRW_PREDICATE_NONE && > - !inst->src[1].abs && !inst->src[1].negate)); > -} > - > bool > fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) > { > @@ -368,7 +357,7 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, > acp_entry *entry) > > if (has_source_modifiers && > entry->dst.type != inst->src[arg].type && > - !can_change_source_types(inst)) > + !inst->can_change_types()) > return false; > > if (devinfo->gen >= 8 && (entry->src.negate || entry->src.abs) && > @@ -438,7 +427,7 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, > acp_entry *entry) > * type. If we got here, then we can just change the source and > * destination types of the instruction and keep going. > */ > - assert(can_change_source_types(inst)); > + assert(inst->can_change_types()); > for (int i = 0; i < inst->sources; i++) { > inst->src[i].type = entry->dst.type; > } > diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h > b/src/mesa/drivers/dri/i965/brw_ir_fs.h > index 97c6f8b..7726e4b 100644 > --- a/src/mesa/drivers/dri/i965/brw_ir_fs.h > +++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h > @@ -204,6 +204,7 @@ public: > unsigned components_read(unsigned i) const; > int regs_read(int arg) const; > bool can_do_source_mods(const struct brw_device_info *devinfo); > + bool can_change_types() const; > bool has_side_effects() const; > > bool reads_flag() const; > diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h > b/src/mesa/drivers/dri/i965/brw_ir_vec4.h > index 96dd633..1b57b65 100644 > --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h > +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h > @@ -179,6 +179,7 @@ public: > int swizzle, int swizzle_mask); > void reswizzle(int dst_writemask, int swizzle); > bool can_do_source_mods(const struct brw_device_info *devinfo); > + bool can_change_types() const; > > bool reads_flag() > { > diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp > b/src/mesa/drivers/dri/i965/brw_vec4.cpp > index 08f3e91..f5242d3 100644 > --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp > +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp > @@ -280,6 +280,18 @@ vec4_instruction::can_do_source_mods(const struct > brw_device_info *devinfo) > return true; > } > > +bool > +vec4_instruction::can_change_types() const > +{ > + return dst.type == src[0].type && > + !src[0].abs && !src[0].negate && !saturate && > + (opcode == BRW_OPCODE_MOV || > + (opcode == BRW_OPCODE_SEL && > + dst.type == src[1].type && > + predicate != BRW_PREDICATE_NONE && > + !src[1].abs && !src[1].negate)); > +} > + > /** > * Returns how many MRFs an opcode will write over. > * > diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp > b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp > index 610caef..db99ecb 100644 > --- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp > +++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp > @@ -256,18 +256,6 @@ try_constant_propagate(const struct brw_device_info > *devinfo, > } > > static bool > -can_change_source_types(vec4_instruction *inst) > -{ > - return inst->dst.type == inst->src[0].type && > - !inst->src[0].abs && !inst->src[0].negate && !inst->saturate && > - (inst->opcode == BRW_OPCODE_MOV || > - (inst->opcode == BRW_OPCODE_SEL && > - inst->dst.type == inst->src[1].type && > - inst->predicate != BRW_PREDICATE_NONE && > - !inst->src[1].abs && !inst->src[1].negate)); > -} > - > -static bool > try_copy_propagate(const struct brw_device_info *devinfo, > vec4_instruction *inst, > int arg, struct copy_entry *entry) > @@ -325,7 +313,7 @@ try_copy_propagate(const struct brw_device_info *devinfo, > > if (has_source_modifiers && > value.type != inst->src[arg].type && > - !can_change_source_types(inst)) > + !inst->can_change_types()) > return false; > > if (has_source_modifiers && > @@ -394,7 +382,7 @@ try_copy_propagate(const struct brw_device_info *devinfo, > value.swizzle = composed_swizzle; > if (has_source_modifiers && > value.type != inst->src[arg].type) { > - assert(can_change_source_types(inst)); > + assert(inst->can_change_types()); > for (int i = 0; i < 3; i++) { > inst->src[i].type = value.type; > } > -- > 2.4.9 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev