glsl: Don't support ir_unop_abs or ir_unop_sign for unsigned integers
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 9 Jul 2016 00:34:53 +0000 (17:34 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 17 Aug 2016 09:52:39 +0000 (10:52 +0100)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/compiler/glsl/ir_constant_expression.cpp
src/compiler/glsl/ir_validate.cpp

index 6329acde2b63b1e981db360e7614d4fc039844be..2d7895e471f8a13afb6b151099a8aa8c426603c5 100644 (file)
@@ -785,9 +785,6 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
    case ir_unop_abs:
       for (unsigned c = 0; c < op[0]->type->components(); c++) {
          switch (this->type->base_type) {
-         case GLSL_TYPE_UINT:
-            data.u[c] = op[0]->value.u[c];
-            break;
          case GLSL_TYPE_INT:
             data.i[c] = op[0]->value.i[c];
             if (data.i[c] < 0)
@@ -808,9 +805,6 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
    case ir_unop_sign:
       for (unsigned c = 0; c < op[0]->type->components(); c++) {
          switch (this->type->base_type) {
-         case GLSL_TYPE_UINT:
-            data.u[c] = op[0]->value.i[c] > 0;
-            break;
          case GLSL_TYPE_INT:
             data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
             break;
index bade45a62ab2c5072b24fbf9b3445259a594accc..3ded20299062a656566e65ccf434f0749849c2a7 100644 (file)
@@ -246,8 +246,17 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
 
    case ir_unop_neg:
+      assert(ir->type == ir->operands[0]->type);
+      break;
+
    case ir_unop_abs:
    case ir_unop_sign:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+      assert(ir->type == ir->operands[0]->type);
+      break;
+
    case ir_unop_rcp:
    case ir_unop_rsq:
    case ir_unop_sqrt: