Mesa (master): glsl2: Track the number of ir_loop_jump instructions that are in a loop

Ian Romanick idr at kemper.freedesktop.org
Fri Sep 3 19:01:04 UTC 2010


Module: Mesa
Branch: master
Commit: 3bcfafcf0320ee5407716ff67062e80d162760d4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3bcfafcf0320ee5407716ff67062e80d162760d4

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Aug 27 15:41:20 2010 -0700

glsl2: Track the number of ir_loop_jump instructions that are in a loop

---

 src/glsl/loop_analysis.cpp |   17 +++++++++++++++++
 src/glsl/loop_analysis.h   |    6 ++++++
 src/glsl/loop_controls.cpp |    4 ++++
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index 2ea2f3d..f1268c0 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -103,6 +103,7 @@ class loop_analysis : public ir_hierarchical_visitor {
 public:
    loop_analysis();
 
+   virtual ir_visitor_status visit(ir_loop_jump *);
    virtual ir_visitor_status visit(ir_dereference_variable *);
 
    virtual ir_visitor_status visit_enter(ir_loop *);
@@ -132,6 +133,22 @@ loop_analysis::loop_analysis()
 
 
 ir_visitor_status
+loop_analysis::visit(ir_loop_jump *ir)
+{
+   (void) ir;
+
+   assert(!this->state.is_empty());
+
+   loop_variable_state *const ls =
+      (loop_variable_state *) this->state.get_head();
+
+   ls->num_loop_jumps++;
+
+   return visit_continue;
+}
+
+
+ir_visitor_status
 loop_analysis::visit(ir_dereference_variable *ir)
 {
    /* If we're not somewhere inside a loop, there's nothing to do.
diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h
index b7c0514..f5c5a04 100644
--- a/src/glsl/loop_analysis.h
+++ b/src/glsl/loop_analysis.h
@@ -104,8 +104,14 @@ public:
     */
    hash_table *var_hash;
 
+   /**
+    * Number of ir_loop_jump instructions that operate on this loop
+    */
+   unsigned num_loop_jumps;
+
    loop_variable_state()
    {
+      this->num_loop_jumps = 0;
       this->var_hash = hash_table_ctor(0, hash_table_pointer_hash,
 				       hash_table_pointer_compare);
    }
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index 9eb1a89..f2e1ecb 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -253,6 +253,10 @@ loop_control_visitor::visit_leave(ir_loop *ir)
 		   * satisfied.
 		   */
 		  if_stmt->remove();
+
+		  assert(ls->num_loop_jumps > 0);
+		  ls->num_loop_jumps--;
+
 		  this->progress = true;
 	       }
 




More information about the mesa-commit mailing list