i965/fs: Allow saturate propagation to propagate negations into MADs.
authorMatt Turner <mattst88@gmail.com>
Wed, 11 Feb 2015 01:45:28 +0000 (17:45 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 25 Feb 2016 18:51:15 +0000 (10:51 -0800)
Allows us to transform

   mad      res  src0   src1   src2
   mov.sat  dst  -res

into

   mad.sat  dst  -src0 -src1   src2

instructions in affected programs: 3712 -> 3688 (-0.65%)
helped: 24

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp

index 7c825097ca26e6acb33a1829049db985d9253cde..dc2b0c8aa8d9b84aa2775ce9cda745f78ae0afec 100644 (file)
@@ -86,6 +86,10 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
                      if (scan_inst->opcode == BRW_OPCODE_MUL) {
                         scan_inst->src[0].negate = !scan_inst->src[0].negate;
                         inst->src[0].negate = false;
+                     } else if (scan_inst->opcode == BRW_OPCODE_MAD) {
+                        scan_inst->src[0].negate = !scan_inst->src[0].negate;
+                        scan_inst->src[1].negate = !scan_inst->src[1].negate;
+                        inst->src[0].negate = false;
                      } else if (scan_inst->opcode == BRW_OPCODE_ADD) {
                         if (scan_inst->src[1].file == IMM) {
                            if (!brw_negate_immediate(scan_inst->src[1].type,