case SHADER_OPCODE_LOAD_PAYLOAD:
return !is_copy_payload(inst);
default:
- return inst->is_tex();
+ return inst->is_send_from_grf() && !inst->has_side_effects();
}
}
a->mlen == b->mlen &&
a->regs_written == b->regs_written &&
a->base_mrf == b->base_mrf &&
- a->sampler == b->sampler &&
a->eot == b->eot &&
a->header_present == b->header_present &&
a->shadow_compare == b->shadow_compare)
}
bool
-fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
+fs_visitor::opt_cse_local(bblock_t *block)
{
bool progress = false;
+ exec_list aeb;
void *cse_ctx = ralloc_context(NULL);
{
bool found = false;
- foreach_in_list_use_after(aeb_entry, entry, aeb) {
+ foreach_in_list_use_after(aeb_entry, entry, &aeb) {
/* Match current instruction's expression against those in AEB. */
if (instructions_match(inst, entry->generator)) {
found = true;
aeb_entry *entry = ralloc(cse_ctx, aeb_entry);
entry->tmp = reg_undef;
entry->generator = inst;
- aeb->push_tail(entry);
+ aeb.push_tail(entry);
} else {
/* This is at least our second sighting of this expression.
* If we don't have a temporary already, make one.
fs_inst *copy;
if (written > 1) {
fs_reg *sources = ralloc_array(mem_ctx, fs_reg, written);
- for (int i = 0; i < written; i++) {
- sources[i] = tmp;
- sources[i].reg_offset = i;
- }
+ for (int i = 0; i < written; i++)
+ sources[i] = offset(tmp, i);
copy = LOAD_PAYLOAD(orig_dst, sources, written);
} else {
copy = MOV(orig_dst, tmp);
copy->force_writemask_all =
entry->generator->force_writemask_all;
}
- entry->generator->insert_after(copy);
+ entry->generator->insert_after(block, copy);
}
/* dest <- temp */
fs_inst *copy;
if (written > 1) {
fs_reg *sources = ralloc_array(mem_ctx, fs_reg, written);
- for (int i = 0; i < written; i++) {
- sources[i] = tmp;
- sources[i].reg_offset = i;
- }
+ for (int i = 0; i < written; i++)
+ sources[i] = offset(tmp, i);
copy = LOAD_PAYLOAD(dst, sources, written);
} else {
copy = MOV(dst, tmp);
copy->force_writemask_all = inst->force_writemask_all;
}
- inst->insert_before(copy);
+ inst->insert_before(block, copy);
}
/* Set our iterator so that next time through the loop inst->next
*/
fs_inst *prev = (fs_inst *)inst->prev;
- inst->remove();
-
- /* Appending an instruction may have changed our bblock end. */
- if (inst == block->end) {
- block->end = prev;
- }
-
+ inst->remove(block);
inst = prev;
}
}
- foreach_in_list_safe(aeb_entry, entry, aeb) {
+ foreach_in_list_safe(aeb_entry, entry, &aeb) {
/* Kill all AEB entries that write a different value to or read from
* the flag register if we just wrote it.
*/
ralloc_free(cse_ctx);
- if (progress)
- invalidate_live_intervals();
-
return progress;
}
calculate_live_intervals();
- cfg_t cfg(&instructions);
-
- for (int b = 0; b < cfg.num_blocks; b++) {
- bblock_t *block = cfg.blocks[b];
- exec_list aeb;
-
- progress = opt_cse_local(block, &aeb) || progress;
+ foreach_block (block, cfg) {
+ progress = opt_cse_local(block) || progress;
}
+ if (progress)
+ invalidate_live_intervals();
+
return progress;
}