i965: Extract can_change_source_types() functions.

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.ekstrand@intel.com>
This commit is contained in:
Matt Turner
2015-10-14 02:12:09 -07:00
parent 41c474df53
commit 9e17c36b8b
6 changed files with 30 additions and 27 deletions
+12
View File
@@ -337,6 +337,18 @@ fs_inst::can_do_source_mods(const struct brw_device_info *devinfo)
return true;
}
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
{
@@ -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;
}
+1
View File
@@ -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;
+1
View File
@@ -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()
{
+12
View File
@@ -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.
*
@@ -255,18 +255,6 @@ try_constant_propagate(const struct brw_device_info *devinfo,
return false;
}
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,
@@ -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;
}