aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/opt_constant_folding.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-04-10 11:33:12 +0200
committermarha <marha@users.sourceforge.net>2012-04-10 11:33:12 +0200
commitd79e641dea89c0d5d651b11971c4c9e14df34629 (patch)
tree59d636ef9c4c21906ea28ac719589f25b9794d0a /mesalib/src/glsl/opt_constant_folding.cpp
parentbf59764a4685c4bef029eddfa75d7496d2a91ae0 (diff)
parentc6f80401dc533b04341afe8d596960d1bc25efce (diff)
downloadvcxsrv-d79e641dea89c0d5d651b11971c4c9e14df34629.tar.gz
vcxsrv-d79e641dea89c0d5d651b11971c4c9e14df34629.tar.bz2
vcxsrv-d79e641dea89c0d5d651b11971c4c9e14df34629.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/os/log.c
Diffstat (limited to 'mesalib/src/glsl/opt_constant_folding.cpp')
-rw-r--r--mesalib/src/glsl/opt_constant_folding.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/mesalib/src/glsl/opt_constant_folding.cpp b/mesalib/src/glsl/opt_constant_folding.cpp
index 599b21525..dcad59997 100644
--- a/mesalib/src/glsl/opt_constant_folding.cpp
+++ b/mesalib/src/glsl/opt_constant_folding.cpp
@@ -117,7 +117,8 @@ ir_constant_folding_visitor::visit_enter(ir_assignment *ir)
ir_visitor_status
ir_constant_folding_visitor::visit_enter(ir_call *ir)
{
- exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
+ /* Attempt to constant fold parameters */
+ exec_list_iterator sig_iter = ir->callee->parameters.iterator();
foreach_iter(exec_list_iterator, iter, *ir) {
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *sig_param = (ir_variable *)sig_iter.get();
@@ -133,6 +134,15 @@ ir_constant_folding_visitor::visit_enter(ir_call *ir)
sig_iter.next();
}
+ /* Next, see if the call can be replaced with an assignment of a constant */
+ ir_constant *const_val = ir->constant_expression_value();
+
+ if (const_val != NULL) {
+ ir_assignment *assignment =
+ new(ralloc_parent(ir)) ir_assignment(ir->return_deref, const_val);
+ ir->replace_with(assignment);
+ }
+
return visit_continue_with_parent;
}