intel/fs: Handle OR source modifiers in algebraic optimization
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 13 Dec 2018 02:14:34 +0000 (18:14 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 1 Mar 2019 20:42:14 +0000 (12:42 -0800)
Found by inspection.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/compiler/brw_fs.cpp

index 470c02145f6d712dbd59fb188343c52282f40de9..c4c800c6c2285f7979aa99f5515487d4d9a2f639 100644 (file)
@@ -2596,7 +2596,16 @@ fs_visitor::opt_algebraic()
       case BRW_OPCODE_OR:
          if (inst->src[0].equals(inst->src[1]) ||
              inst->src[1].is_zero()) {
-            inst->opcode = BRW_OPCODE_MOV;
+            /* On Gen8+, the OR instruction can have a source modifier that
+             * performs logical not on the operand.  Cases of 'OR r0, ~r1, 0'
+             * or 'OR r0, ~r1, ~r1' should become a NOT instead of a MOV.
+             */
+            if (inst->src[0].negate) {
+               inst->opcode = BRW_OPCODE_NOT;
+               inst->src[0].negate = false;
+            } else {
+               inst->opcode = BRW_OPCODE_MOV;
+            }
             inst->src[1] = reg_undef;
             progress = true;
             break;