*/
#include "brw_fs.h"
-#include "brw_fs_live_variables.h"
#include "brw_cfg.h"
+#include "brw_eu.h"
/** @file brw_fs_cmod_propagation.cpp
*
*/
static bool
-opt_cmod_propagation_local(bblock_t *block)
+opt_cmod_propagation_local(const brw_device_info *devinfo, bblock_t *block)
{
bool progress = false;
int ip = block->end_ip + 1;
inst->opcode != BRW_OPCODE_MOV) ||
inst->predicate != BRW_PREDICATE_NONE ||
!inst->dst.is_null() ||
- inst->src[0].file != GRF ||
+ inst->src[0].file != VGRF ||
inst->src[0].abs)
continue;
foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst) {
if (scan_inst->overwrites_reg(inst->src[0])) {
if (scan_inst->is_partial_write() ||
- scan_inst->dst.reg_offset != inst->src[0].reg_offset)
+ scan_inst->dst.reg_offset != inst->src[0].reg_offset ||
+ scan_inst->exec_size != inst->exec_size)
break;
/* CMP's result is the same regardless of dest type. */
*/
if (inst->conditional_mod == BRW_CONDITIONAL_NZ &&
!inst->src[0].negate &&
- scan_inst->writes_flag()) {
+ scan_inst->flags_written()) {
inst->remove(block);
progress = true;
break;
}
+ /* The conditional mod of the CMP/CMPN instructions behaves
+ * specially because the flag output is not calculated from the
+ * result of the instruction, but the other way around, which
+ * means that even if the condmod to propagate and the condmod
+ * from the CMP instruction are the same they will in general give
+ * different results because they are evaluated based on different
+ * inputs.
+ */
+ if (scan_inst->opcode == BRW_OPCODE_CMP ||
+ scan_inst->opcode == BRW_OPCODE_CMPN)
+ break;
+
/* Otherwise, try propagating the conditional. */
enum brw_conditional_mod cond =
inst->src[0].negate ? brw_swap_cmod(inst->conditional_mod)
break;
}
- if (scan_inst->writes_flag())
+ if (scan_inst->flags_written())
break;
- read_flag = read_flag || scan_inst->reads_flag();
+ read_flag = read_flag || scan_inst->flags_read(devinfo);
}
}
bool progress = false;
foreach_block_reverse(block, cfg) {
- progress = opt_cmod_propagation_local(block) || progress;
+ progress = opt_cmod_propagation_local(devinfo, block) || progress;
}
if (progress)