Mesa (master): glsl2: Use as_constant some places instead of constant_expression_value

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


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Sep  2 14:53:17 2010 -0700

glsl2: Use as_constant some places instead of constant_expression_value

The places where constant_expression_value are still used in loop
analysis are places where a new expression tree is created and
constant folding won't have happened.  This is used, for example, when
we try to determine the maximal loop iteration count.

Based on review comments by Eric.  "...rely on constant folding to
have done its job, instead of going all through the subtree again when
it wasn't a constant."

---

 src/glsl/loop_analysis.cpp |    2 +-
 src/glsl/loop_controls.cpp |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index f1268c0..32e8b8c 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -433,7 +433,7 @@ get_basic_induction_increment(ir_assignment *ir, hash_table *var_hash)
 
    ir_rvalue *inc = (op0 == var) ? rhs->operands[1] : rhs->operands[0];
 
-   if (inc->constant_expression_value() == NULL) {
+   if (inc->as_constant() == NULL) {
       ir_variable *const inc_var = inc->variable_referenced();
       if (inc_var != NULL) {
 	 loop_variable *lv =
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index d6a1e33..17a0d2d 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -204,12 +204,12 @@ loop_control_visitor::visit_leave(ir_loop *ir)
 	  * which.
 	  */
 	 ir_rvalue *counter = cond->operands[0]->as_dereference_variable();
-	 ir_constant *limit = cond->operands[1]->constant_expression_value();
+	 ir_constant *limit = cond->operands[1]->as_constant();
 	 enum ir_expression_operation cmp = cond->operation;
 
 	 if (limit == NULL) {
 	    counter = cond->operands[1]->as_dereference_variable();
-	    limit = cond->operands[0]->constant_expression_value();
+	    limit = cond->operands[0]->as_constant();
 
 	    switch (cmp) {
 	    case ir_binop_less:    cmp = ir_binop_gequal;  break;




More information about the mesa-commit mailing list