[Mesa-dev] [PATCH 10/13] i965 vs: Make a separate optimize() method.

Paul Berry stereotype441 at gmail.com
Wed Nov 16 11:07:17 PST 2011


This patch moves vec4_visitor::run()'s optimization loop to its own
method.

This helps pave the way for separating the IR visiting parts of
vec4_visitor from the code generation parts, by reducing the number of
function calls between the two parts.
---
 src/mesa/drivers/dri/i965/brw_vec4.h        |    1 +
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |   23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index c0284fc..5d2f120 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -411,6 +411,7 @@ public:
    bool opt_copy_propagation();
    bool opt_algebraic();
    bool opt_compute_to_mrf();
+   void optimize();
 
    vec4_instruction *emit(vec4_instruction *inst);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index dceacc7..5724a29 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -622,6 +622,19 @@ vec4_visitor::generate_vs_instruction(vec4_instruction *instruction,
 }
 
 void
+vec4_visitor::optimize()
+{
+   bool progress;
+   do {
+      progress = false;
+      progress = dead_code_eliminate() || progress;
+      progress = opt_copy_propagation() || progress;
+      progress = opt_algebraic() || progress;
+      progress = opt_compute_to_mrf() || progress;
+   } while (progress);
+}
+
+void
 vec4_visitor::run()
 {
    if (c->key.userclip_active && !c->key.uses_clip_distance)
@@ -645,15 +658,7 @@ vec4_visitor::run()
    pack_uniform_registers();
    move_push_constants_to_pull_constants();
 
-   bool progress;
-   do {
-      progress = false;
-      progress = dead_code_eliminate() || progress;
-      progress = opt_copy_propagation() || progress;
-      progress = opt_algebraic() || progress;
-      progress = opt_compute_to_mrf() || progress;
-   } while (progress);
-
+   optimize();
 
    if (failed())
       return;
-- 
1.7.6.4



More information about the mesa-dev mailing list