glsl2: Track the number of ir_loop_jump instructions that are in a loop
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Aug 2010 22:41:20 +0000 (15:41 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 3 Sep 2010 18:55:22 +0000 (11:55 -0700)
src/glsl/loop_analysis.cpp
src/glsl/loop_analysis.h
src/glsl/loop_controls.cpp

index 2ea2f3dbe39a59b728f52b8c1a9ae84b68dadf21..f1268c04c4d4e34760804073b7343cbbdc0cbe04 100644 (file)
@@ -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 *);
@@ -131,6 +132,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)
 {
index b7c05149438c37d0f521638b701f3fbfca8a793c..f5c5a04be81d3463dbb48bb6d1a9deebe6edd1eb 100644 (file)
@@ -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);
    }
index 9eb1a8901b0fb5c4832bff0d7eecddd4c0dc10f5..f2e1ecb904daf2cb3cff29f1ccc040cc018a78fe 100644 (file)
@@ -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;
               }