intel/ir: Remove scheduling-based cycle count estimates.
[mesa.git] / src / intel / compiler / brw_fs_saturate_propagation.cpp
index 1c97a507d8cd40c968b1e972274cc20317dc1bf6..50c3fc19f3beedba8dab8dded8973751a02c49e6 100644 (file)
@@ -25,6 +25,8 @@
 #include "brw_fs_live_variables.h"
 #include "brw_cfg.h"
 
+using namespace brw;
+
 /** @file brw_fs_saturate_propagation.cpp
  *
  * Implements a pass that propagates the SAT modifier from a MOV.SAT into the
@@ -43,7 +45,7 @@
  */
 
 static bool
-opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
+opt_saturate_propagation_local(const fs_live_variables &live, bblock_t *block)
 {
    bool progress = false;
    int ip = block->end_ip + 1;
@@ -59,12 +61,13 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
           inst->src[0].abs)
          continue;
 
-      int src_var = v->live_intervals->var_from_reg(inst->src[0]);
-      int src_end_ip = v->live_intervals->end[src_var];
+      int src_var = live.var_from_reg(inst->src[0]);
+      int src_end_ip = live.end[src_var];
 
       bool interfered = false;
       foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst) {
-         if (regions_overlap(scan_inst->dst, scan_inst->size_written,
+         if (scan_inst->exec_size == inst->exec_size &&
+             regions_overlap(scan_inst->dst, scan_inst->size_written,
                              inst->src[0], inst->size_read(0))) {
             if (scan_inst->is_partial_write() ||
                 (scan_inst->dst.type != inst->dst.type &&
@@ -88,8 +91,14 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
                         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;
+                        for (int i = 0; i < 2; i++) {
+                           if (scan_inst->src[i].file == IMM) {
+                              brw_negate_immediate(scan_inst->src[i].type,
+                                                   &scan_inst->src[i].as_brw_reg());
+                           } else {
+                              scan_inst->src[i].negate = !scan_inst->src[i].negate;
+                           }
+                        }
                         inst->src[0].negate = false;
                      } else if (scan_inst->opcode == BRW_OPCODE_ADD) {
                         if (scan_inst->src[1].file == IMM) {
@@ -142,12 +151,11 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
 bool
 fs_visitor::opt_saturate_propagation()
 {
+   const fs_live_variables &live = live_analysis.require();
    bool progress = false;
 
-   calculate_live_intervals();
-
    foreach_block (block, cfg) {
-      progress = opt_saturate_propagation_local(this, block) || progress;
+      progress = opt_saturate_propagation_local(live, block) || progress;
    }
 
    /* Live intervals are still valid. */