[Mesa-dev] [PATCH 3/3] glsl: Remove extra checks for constant true assignment conditions.
Eric Anholt
eric at anholt.net
Sat Jan 29 23:03:21 PST 2011
These are already stripped by opt_constant_folding.cpp.
---
src/glsl/opt_constant_propagation.cpp | 7 ++-----
src/glsl/opt_constant_variable.cpp | 7 ++-----
src/glsl/opt_copy_propagation.cpp | 7 ++-----
src/glsl/opt_copy_propagation_elements.cpp | 7 ++-----
src/glsl/opt_dead_code_local.cpp | 9 +--------
5 files changed, 9 insertions(+), 28 deletions(-)
diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp
index 6719fc8..0b8905f 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -398,11 +398,8 @@ ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
{
acp_entry *entry;
- if (ir->condition) {
- ir_constant *condition = ir->condition->as_constant();
- if (!condition || !condition->value.b[0])
- return;
- }
+ if (ir->condition)
+ return;
if (!ir->write_mask)
return;
diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp
index 8068d0c..3fa7c3b 100644
--- a/src/glsl/opt_constant_variable.cpp
+++ b/src/glsl/opt_constant_variable.cpp
@@ -104,11 +104,8 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
/* OK, now find if we actually have all the right conditions for
* this to be a constant value assigned to the var.
*/
- if (ir->condition) {
- constval = ir->condition->constant_expression_value();
- if (!constval || !constval->value.b[0])
- return visit_continue;
- }
+ if (ir->condition)
+ return visit_continue;
ir_variable *var = ir->whole_variable_written();
if (!var)
diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp
index 2399748..fba2661 100644
--- a/src/glsl/opt_copy_propagation.cpp
+++ b/src/glsl/opt_copy_propagation.cpp
@@ -309,11 +309,8 @@ ir_copy_propagation_visitor::add_copy(ir_assignment *ir)
{
acp_entry *entry;
- if (ir->condition) {
- ir_constant *condition = ir->condition->as_constant();
- if (!condition || !condition->value.b[0])
- return;
- }
+ if (ir->condition)
+ return;
ir_variable *lhs_var = ir->whole_variable_written();
ir_variable *rhs_var = ir->rhs->whole_variable_referenced();
diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp
index 39993e0..534bcf8 100644
--- a/src/glsl/opt_copy_propagation_elements.cpp
+++ b/src/glsl/opt_copy_propagation_elements.cpp
@@ -409,11 +409,8 @@ ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir)
int orig_swizzle[4] = {0, 1, 2, 3};
int swizzle[4];
- if (ir->condition) {
- ir_constant *condition = ir->condition->as_constant();
- if (!condition || !condition->value.b[0])
- return;
- }
+ if (ir->condition)
+ return;
ir_dereference_variable *lhs = ir->lhs->as_dereference_variable();
if (!lhs || !(lhs->type->is_scalar() || lhs->type->is_vector()))
diff --git a/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp
index 5689e7d..3780ea0 100644
--- a/src/glsl/opt_dead_code_local.cpp
+++ b/src/glsl/opt_dead_code_local.cpp
@@ -129,15 +129,8 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
var = ir->lhs->variable_referenced();
assert(var);
- bool always_assign = true;
- if (ir->condition) {
- ir_constant *condition = ir->condition->as_constant();
- if (!condition || !condition->value.b[0])
- always_assign = false;
- }
-
/* Now, check if we did a whole-variable assignment. */
- if (always_assign && (ir->whole_variable_written() != NULL)) {
+ if (!ir->condition && (ir->whole_variable_written() != NULL)) {
/* We did a whole-variable assignment. So, any instruction in
* the assignment list with the same LHS is dead.
*/
--
1.7.2.3
More information about the mesa-dev
mailing list