summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/opt_constant_propagation.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-04-29 14:40:26 -0700
committerKenneth Graunke <[email protected]>2016-05-15 23:59:20 -0700
commit329fe93210ce8f603f831ebd8431786d12cd1057 (patch)
treeede5b4b2a66fe4cce14aa0e3204e7feea0533351 /src/compiler/glsl/opt_constant_propagation.cpp
parent3bf27a9a002fd5c23937e4e34aff35c94824008f (diff)
glsl: Consolidate duplicate copies of constant folding.
We could probably clean this up more (maybe make it a method), but at least there's only one copy of this code now, and that's a start. No change in shader-db. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/compiler/glsl/opt_constant_propagation.cpp')
-rw-r--r--src/compiler/glsl/opt_constant_propagation.cpp29
1 files changed, 3 insertions, 26 deletions
diff --git a/src/compiler/glsl/opt_constant_propagation.cpp b/src/compiler/glsl/opt_constant_propagation.cpp
index 4764d16de6d..4b82bd13f9f 100644
--- a/src/compiler/glsl/opt_constant_propagation.cpp
+++ b/src/compiler/glsl/opt_constant_propagation.cpp
@@ -136,33 +136,10 @@ public:
void
-ir_constant_propagation_visitor::constant_folding(ir_rvalue **rvalue) {
-
- if (*rvalue == NULL || (*rvalue)->ir_type == ir_type_constant)
- return;
-
- /* Note that we visit rvalues one leaving. So if an expression has a
- * non-constant operand, no need to go looking down it to find if it's
- * constant. This cuts the time of this pass down drastically.
- */
- ir_expression *expr = (*rvalue)->as_expression();
- if (expr) {
- for (unsigned int i = 0; i < expr->get_num_operands(); i++) {
- if (!expr->operands[i]->as_constant())
- return;
- }
- }
-
- /* Ditto for swizzles. */
- ir_swizzle *swiz = (*rvalue)->as_swizzle();
- if (swiz && !swiz->val->as_constant())
- return;
-
- ir_constant *constant = (*rvalue)->constant_expression_value();
- if (constant) {
- *rvalue = constant;
+ir_constant_propagation_visitor::constant_folding(ir_rvalue **rvalue)
+{
+ if (ir_constant_fold(rvalue))
this->progress = true;
- }
}
void