+ return a->opcode == b->opcode &&
+ a->force_writemask_all == b->force_writemask_all &&
+ a->exec_size == b->exec_size &&
+ a->group == b->group &&
+ a->saturate == b->saturate &&
+ a->predicate == b->predicate &&
+ a->predicate_inverse == b->predicate_inverse &&
+ a->conditional_mod == b->conditional_mod &&
+ a->flag_subreg == b->flag_subreg &&
+ a->dst.type == b->dst.type &&
+ a->offset == b->offset &&
+ a->mlen == b->mlen &&
+ a->size_written == b->size_written &&
+ a->base_mrf == b->base_mrf &&
+ a->eot == b->eot &&
+ a->header_size == b->header_size &&
+ a->shadow_compare == b->shadow_compare &&
+ a->pi_noperspective == b->pi_noperspective &&
+ a->target == b->target &&
+ a->sources == b->sources &&
+ operands_match(a, b, negate);
+}
+
+static void
+create_copy_instr(const fs_builder &bld, fs_inst *inst, fs_reg src, bool negate)
+{
+ unsigned written = regs_written(inst);
+ unsigned dst_width =
+ DIV_ROUND_UP(inst->dst.component_size(inst->exec_size), REG_SIZE);
+ fs_inst *copy;
+
+ if (inst->opcode == SHADER_OPCODE_LOAD_PAYLOAD ||
+ written != dst_width) {
+ fs_reg *payload;
+ int sources, header_size;
+ if (inst->opcode == SHADER_OPCODE_LOAD_PAYLOAD) {
+ sources = inst->sources;
+ header_size = inst->header_size;
+ } else {
+ assert(written % dst_width == 0);
+ sources = written / dst_width;
+ header_size = 0;
+ }
+
+ assert(src.file == VGRF);
+ payload = ralloc_array(bld.shader->mem_ctx, fs_reg, sources);
+ for (int i = 0; i < header_size; i++) {
+ payload[i] = src;
+ src.offset += REG_SIZE;
+ }
+ for (int i = header_size; i < sources; i++) {
+ payload[i] = src;
+ src = offset(src, bld, 1);
+ }
+ copy = bld.LOAD_PAYLOAD(inst->dst, payload, sources, header_size);
+ } else {
+ copy = bld.MOV(inst->dst, src);
+ copy->group = inst->group;
+ copy->force_writemask_all = inst->force_writemask_all;
+ copy->src[0].negate = negate;
+ }
+ assert(regs_written(copy) == written);