inst->opcode != BRW_OPCODE_ENDIF);
}
+static bool
+is_channel_updated(vec4_instruction *inst, src_reg *values[4], int ch)
+{
+ const src_reg *src = values[ch];
+
+ /* consider GRF only */
+ assert(inst->dst.file == GRF);
+ if (!src || src->file != GRF)
+ return false;
+
+ return (src->reg == inst->dst.reg &&
+ src->reg_offset == inst->dst.reg_offset &&
+ inst->dst.writemask & (1 << BRW_GET_SWZ(src->swizzle, ch)));
+}
+
static bool
try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4])
{
*/
src_reg value = *values[0];
for (int i = 1; i < 4; i++) {
- if (!value.equals(values[i]))
+ if (!value.equals(*values[i]))
return false;
}
return false;
}
+static bool
+is_logic_op(enum opcode opcode)
+{
+ return (opcode == BRW_OPCODE_AND ||
+ opcode == BRW_OPCODE_OR ||
+ opcode == BRW_OPCODE_XOR ||
+ opcode == BRW_OPCODE_NOT);
+}
+
bool
vec4_visitor::try_copy_propagation(vec4_instruction *inst, int arg,
src_reg *values[4])
value.file != ATTR)
return false;
+ if (brw->gen >= 8) {
+ if (value.negate) {
+ if (is_logic_op(inst->opcode)) {
+ return false;
+ }
+ }
+ }
+
if (inst->src[arg].abs) {
value.negate = false;
value.abs = true;
* instructions.
*/
if ((has_source_modifiers || value.file == UNIFORM ||
- value.swizzle != BRW_SWIZZLE_XYZW) && !can_do_source_mods(inst))
+ value.swizzle != BRW_SWIZZLE_XYZW) && !inst->can_do_source_mods(brw))
return false;
if (has_source_modifiers && value.type != inst->src[arg].type)
return false;
/* Don't report progress if this is a noop. */
- if (value.equals(&inst->src[arg]))
+ if (value.equals(inst->src[arg]))
return false;
value.type = inst->src[arg].type;
else {
for (int i = 0; i < virtual_grf_reg_count; i++) {
for (int j = 0; j < 4; j++) {
- if (inst->dst.writemask & (1 << j) &&
- cur_value[i][j] &&
- cur_value[i][j]->file == GRF &&
- cur_value[i][j]->reg == inst->dst.reg &&
- cur_value[i][j]->reg_offset == inst->dst.reg_offset) {
+ if (is_channel_updated(inst, cur_value[i], j)){
cur_value[i][j] = NULL;
}
}