summaryrefslogtreecommitdiff
path: root/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-04-06 10:02:27 -0700
committerEric Anholt <eric@anholt.net>2010-04-06 11:42:34 -0700
commitec1949e8041b63f59aab63440ad9eeeddd226ce3 (patch)
treed95943a522de3cc3b133c587afdf411f218f57d9 /ir_constant_expression.cpp
parent85171c2dd8c7050511cb7708d75e574005262bf0 (diff)
Add support for =, != to ir_constant_expresion.cpp
This results in constant folding of one more expression in CorrectParse2.frag.
Diffstat (limited to 'ir_constant_expression.cpp')
-rw-r--r--ir_constant_expression.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp
index f90c69b..6325df5 100644
--- a/ir_constant_expression.cpp
+++ b/ir_constant_expression.cpp
@@ -318,6 +318,49 @@ ir_constant_visitor::visit(ir_expression *ir)
}
break;
+ case ir_binop_equal:
+ if (ir->operands[0]->type == ir->operands[1]->type) {
+ type = glsl_type::bool_type;
+ b[0] = true;
+ for (c = 0; c < ir->operands[0]->type->components(); c++) {
+ switch (ir->operands[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ b[0] = b[0] && op[0]->value.u[c] == op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ b[0] = b[0] && op[0]->value.i[c] == op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ b[0] = b[0] && op[0]->value.f[c] == op[1]->value.f[c];
+ break;
+ default:
+ assert(0);
+ }
+ }
+ }
+ break;
+ case ir_binop_nequal:
+ if (ir->operands[0]->type == ir->operands[1]->type) {
+ type = glsl_type::bool_type;
+ b[0] = false;
+ for (c = 0; c < ir->operands[0]->type->components(); c++) {
+ switch (ir->operands[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ b[0] = b[0] || op[0]->value.u[c] != op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ b[0] = b[0] || op[0]->value.i[c] != op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ b[0] = b[0] || op[0]->value.f[c] != op[1]->value.f[c];
+ break;
+ default:
+ assert(0);
+ }
+ }
+ }
+ break;
+
default:
break;
}