i965: Move fs_visitor optimization pass into new method fs_visitor::optimize()
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 14 Nov 2014 00:28:18 +0000 (16:28 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 15 Nov 2014 03:38:06 +0000 (19:38 -0800)
We'll reuse this toplevel optimization driver for the scalar VS.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h

index 0bdd8abcf8ab83785bcb4063e8b15d1993567518..d2e963fc48289957cb48857489dc0e1f4d14fc32 100644 (file)
@@ -3443,6 +3443,76 @@ fs_visitor::opt_drop_redundant_mov_to_flags()
    }
 }
 
+void
+fs_visitor::optimize()
+{
+   calculate_cfg();
+
+   split_virtual_grfs();
+
+   move_uniform_array_access_to_pull_constants();
+   assign_constant_locations();
+   demote_pull_constants();
+
+   opt_drop_redundant_mov_to_flags();
+
+#define OPT(pass, args...) do {                                         \
+      pass_num++;                                                       \
+      bool this_progress = pass(args);                                  \
+                                                                        \
+      if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER) && this_progress) {   \
+         char filename[64];                                             \
+         snprintf(filename, 64, "fs%d-%04d-%02d-%02d-" #pass,           \
+                  dispatch_width, shader_prog ? shader_prog->Name : 0, iteration, pass_num); \
+                                                                        \
+         backend_visitor::dump_instructions(filename);                  \
+      }                                                                 \
+                                                                        \
+      progress = progress || this_progress;                             \
+   } while (false)
+
+   if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER)) {
+      char filename[64];
+      snprintf(filename, 64, "fs%d-%04d-00-start",
+               dispatch_width, shader_prog ? shader_prog->Name : 0);
+
+      backend_visitor::dump_instructions(filename);
+   }
+
+   bool progress;
+   int iteration = 0;
+   do {
+      progress = false;
+      iteration++;
+      int pass_num = 0;
+
+      OPT(remove_duplicate_mrf_writes);
+
+      OPT(opt_algebraic);
+      OPT(opt_cse);
+      OPT(opt_copy_propagate);
+      OPT(opt_peephole_predicated_break);
+      OPT(dead_code_eliminate);
+      OPT(opt_peephole_sel);
+      OPT(dead_control_flow_eliminate, this);
+      OPT(opt_register_renaming);
+      OPT(opt_saturate_propagation);
+      OPT(register_coalesce);
+      OPT(compute_to_mrf);
+
+      OPT(compact_virtual_grfs);
+   } while (progress);
+
+   if (lower_load_payload()) {
+      split_virtual_grfs();
+      register_coalesce();
+      compute_to_mrf();
+      dead_code_eliminate();
+   }
+
+   lower_uniform_pull_constant_loads();
+}
+
 bool
 fs_visitor::run()
 {
@@ -3510,71 +3580,7 @@ fs_visitor::run()
 
       emit_fb_writes();
 
-      calculate_cfg();
-
-      split_virtual_grfs();
-
-      move_uniform_array_access_to_pull_constants();
-      assign_constant_locations();
-      demote_pull_constants();
-
-      opt_drop_redundant_mov_to_flags();
-
-#define OPT(pass, args...) do {                                            \
-      pass_num++;                                                          \
-      bool this_progress = pass(args);                                     \
-                                                                           \
-      if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER) && this_progress) {      \
-         char filename[64];                                                \
-         snprintf(filename, 64, "fs%d-%04d-%02d-%02d-" #pass,              \
-                  dispatch_width, shader_prog ? shader_prog->Name : 0, iteration, pass_num); \
-                                                                           \
-         backend_visitor::dump_instructions(filename);                     \
-      }                                                                    \
-                                                                           \
-      progress = progress || this_progress;                                \
-   } while (false)
-
-      if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER)) {
-         char filename[64];
-         snprintf(filename, 64, "fs%d-%04d-00-start",
-                  dispatch_width, shader_prog ? shader_prog->Name : 0);
-
-         backend_visitor::dump_instructions(filename);
-      }
-
-      bool progress;
-      int iteration = 0;
-      do {
-        progress = false;
-         iteration++;
-         int pass_num = 0;
-
-         OPT(remove_duplicate_mrf_writes);
-
-         OPT(opt_algebraic);
-         OPT(opt_cse);
-         OPT(opt_copy_propagate);
-         OPT(opt_peephole_predicated_break);
-         OPT(dead_code_eliminate);
-         OPT(opt_peephole_sel);
-         OPT(dead_control_flow_eliminate, this);
-         OPT(opt_register_renaming);
-         OPT(opt_saturate_propagation);
-         OPT(register_coalesce);
-         OPT(compute_to_mrf);
-
-         OPT(compact_virtual_grfs);
-      } while (progress);
-
-      if (lower_load_payload()) {
-         split_virtual_grfs();
-         register_coalesce();
-         compute_to_mrf();
-         dead_code_eliminate();
-      }
-
-      lower_uniform_pull_constant_loads();
+      optimize();
 
       assign_curb_setup();
       assign_urb_setup();
index 8a8b72158bd3993814d8197e625c65cc5a127a43..676087ed87624351b25268c2f7e01e48697dd015 100644 (file)
@@ -403,6 +403,7 @@ public:
                                         uint32_t const_offset);
 
    bool run();
+   void optimize();
    void assign_binding_table_offsets();
    void setup_payload_gen4();
    void setup_payload_gen6();