+ fs_reg *xs = a->src;
+ fs_reg *ys = b->src;
+
+ if (a->opcode == BRW_OPCODE_MAD) {
+ return xs[0].equals(ys[0]) &&
+ ((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) ||
+ (xs[2].equals(ys[1]) && xs[1].equals(ys[2])));
+ } else if (!a->is_commutative()) {
+ bool match = true;
+ for (int i = 0; i < a->sources; i++) {
+ if (!xs[i].equals(ys[i])) {
+ match = false;
+ break;
+ }
+ }
+ return match;
+ } else {
+ return (xs[0].equals(ys[0]) && xs[1].equals(ys[1])) ||
+ (xs[1].equals(ys[0]) && xs[0].equals(ys[1]));
+ }
+}
+
+static bool
+instructions_match(fs_inst *a, fs_inst *b)
+{
+ return a->opcode == b->opcode &&
+ a->saturate == b->saturate &&
+ a->predicate == b->predicate &&
+ a->predicate_inverse == b->predicate_inverse &&
+ a->conditional_mod == b->conditional_mod &&
+ a->dst.type == b->dst.type &&
+ a->sources == b->sources &&
+ (a->is_tex() ? (a->offset == b->offset &&
+ a->mlen == b->mlen &&
+ a->regs_written == b->regs_written &&
+ a->base_mrf == b->base_mrf &&
+ a->eot == b->eot &&
+ a->header_present == b->header_present &&
+ a->shadow_compare == b->shadow_compare)
+ : true) &&
+ operands_match(a, b);