intel/fs: Merge copy prop dataflow loops
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 14 Sep 2023 00:52:29 +0000 (17:52 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 14 Sep 2023 22:31:23 +0000 (22:31 +0000)
This is kept as a separate commit because the change looks like a lot
more than it it. The order of the two loops is swapped, then the two
loops are merged.

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25091>

src/intel/compiler/brw_fs_copy_propagation.cpp

index fd38567..6a8429f 100644 (file)
@@ -374,33 +374,29 @@ fs_copy_prop_dataflow::setup_initial_values()
 
       foreach_block (block, cfg) {
          foreach_inst_in_block(fs_inst, inst, block) {
-            if (inst->dst.file != VGRF)
+            if (inst->dst.file != VGRF &&
+                inst->dst.file != FIXED_GRF)
                continue;
 
-            for (auto iter = acp_table.find_by_dst(inst->dst.nr);
-              iter != acp_table.end() && (*iter)->dst.nr == inst->dst.nr;
+            for (auto iter = acp_table.find_by_src(inst->dst.nr);
+              iter != acp_table.end() && (*iter)->src.nr == inst->dst.nr;
               ++iter) {
                if (grf_regions_overlap(inst->dst, inst->size_written,
-                                       (*iter)->dst, (*iter)->size_written)) {
+                                       (*iter)->src, (*iter)->size_read)) {
                   BITSET_SET(bd[block->num].kill, (*iter)->global_idx);
                   if (inst->force_writemask_all && !(*iter)->force_writemask_all)
                      BITSET_SET(bd[block->num].exec_mismatch, (*iter)->global_idx);
                }
             }
-         }
-      }
 
-      foreach_block (block, cfg) {
-         foreach_inst_in_block(fs_inst, inst, block) {
-            if (inst->dst.file != VGRF &&
-                inst->dst.file != FIXED_GRF)
+            if (inst->dst.file != VGRF)
                continue;
 
-            for (auto iter = acp_table.find_by_src(inst->dst.nr);
-              iter != acp_table.end() && (*iter)->src.nr == inst->dst.nr;
+            for (auto iter = acp_table.find_by_dst(inst->dst.nr);
+              iter != acp_table.end() && (*iter)->dst.nr == inst->dst.nr;
               ++iter) {
                if (grf_regions_overlap(inst->dst, inst->size_written,
-                                       (*iter)->src, (*iter)->size_read)) {
+                                       (*iter)->dst, (*iter)->size_written)) {
                   BITSET_SET(bd[block->num].kill, (*iter)->global_idx);
                   if (inst->force_writemask_all && !(*iter)->force_writemask_all)
                      BITSET_SET(bd[block->num].exec_mismatch, (*iter)->global_idx);