ir_constant_expression: Remove open coded equality comparisons.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 20 Jul 2010 10:01:54 +0000 (03:01 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 21 Jul 2010 23:38:32 +0000 (16:38 -0700)
The ir_constant::has_value method already does this.

src/glsl/ir_constant_expression.cpp

index cb07f381281c6e235b02f153d32791575ae24de0..b0333dbebb75db120e9de9317f40235730b7f469 100644 (file)
@@ -603,46 +603,10 @@ ir_expression::constant_expression_value()
       break;
 
    case ir_binop_equal:
-      data.b[0] = true;
-      for (unsigned c = 0; c < op[0]->type->components(); c++) {
-        switch (op[0]->type->base_type) {
-        case GLSL_TYPE_UINT:
-           data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c];
-           break;
-        case GLSL_TYPE_INT:
-           data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c];
-           break;
-        case GLSL_TYPE_FLOAT:
-           data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c];
-           break;
-        case GLSL_TYPE_BOOL:
-           data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c];
-           break;
-        default:
-           assert(0);
-        }
-      }
+      data.b[0] = op[0]->has_value(op[1]);
       break;
    case ir_binop_nequal:
-      data.b[0] = false;
-      for (unsigned c = 0; c < op[0]->type->components(); c++) {
-        switch (op[0]->type->base_type) {
-        case GLSL_TYPE_UINT:
-           data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c];
-           break;
-        case GLSL_TYPE_INT:
-           data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c];
-           break;
-        case GLSL_TYPE_FLOAT:
-           data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c];
-           break;
-        case GLSL_TYPE_BOOL:
-           data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c];
-           break;
-        default:
-           assert(0);
-        }
-      }
+      data.b[0] = !op[0]->has_value(op[1]);
       break;
 
    default: