[Mesa-dev] [PATCH] i965: Consider SEL.{GE, L} to be commutative operations.

Kenneth Graunke kenneth at whitecape.org
Sun Dec 21 19:50:18 PST 2014


On Sunday, December 21, 2014 03:37:25 PM Matt Turner wrote:
> ---
> No shader-db changes, unfortunately.

Unsurprising :) This patch doesn't implement what you meant.

1. instructions_match() checks a->conditional_mod == b->conditional_mod.
   So you won't ever see mixed conditional mods in operands_match() or
   is_expression_commutative().  I suspect this is why you see no changes.

2. It looks like your patch allows CSE of (a >= b) with (b >= a),
   which are clearly different.  So any changes would be wrong.

What you want is to use brw_swap_cmod.  It's then trivial to handle /all/
comparitors, not just L/GE.  I think what you want is:

static bool
instructions match(fs_inst *a, fs_inst *b)
{
   bool match = a->opcode == b->opcode &&
                a->saturate == b->saturate &&
                a->predicate == b->predicate &&
                a->predicate_inverse == b->predicate_inverse &&
                a->dst.type == b->dst.type &&
                a->sources == b->sources;

   if (a->is_tex()) {
       match = match &&
               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);
   }

   if (!match)
      return false;

   /* Comparisons match if both the comparitor and operands are flipped. */
   if (a->opcode == BRW_OPCODE_SEL &&
       a->conditional_mod == brw_swap_cmod(b->conditional_mod)
       a->src[0].equals(b->src[1]) && a->src[1].equals(b->src[0])) {
      return true;
   }

   return a->conditional_mod == b->conditional_mod && operands_match(a, b);
}

I'm also not sure why you special case SEL - it seems like CMP would work fine
as well, and would probably help even more.  Maybe just drop the opcode check.

FWIW, I haven't tested the above code.

--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141221/e9d73096/attachment.sig>


More information about the mesa-dev mailing list