do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, ir_rvalue *op1)
{
int join_op;
+ ir_rvalue *cmp = NULL;
if (operation == ir_binop_all_equal)
join_op = ir_binop_logic_and;
return new(mem_ctx) ir_expression(operation, op0, op1);
case GLSL_TYPE_ARRAY: {
- ir_rvalue *last = NULL;
-
for (unsigned int i = 0; i < op0->type->length; i++) {
ir_rvalue *e0, *e1, *result;
new(mem_ctx) ir_constant(i));
result = do_comparison(mem_ctx, operation, e0, e1);
- if (last) {
- last = new(mem_ctx) ir_expression(join_op, last, result);
+ if (cmp) {
+ cmp = new(mem_ctx) ir_expression(join_op, cmp, result);
} else {
- last = result;
+ cmp = result;
}
}
mark_whole_array_access(op0);
mark_whole_array_access(op1);
-
- return last;
+ break;
}
case GLSL_TYPE_STRUCT: {
- ir_rvalue *last = NULL;
-
for (unsigned int i = 0; i < op0->type->length; i++) {
ir_rvalue *e0, *e1, *result;
const char *field_name = op0->type->fields.structure[i].name;
field_name);
result = do_comparison(mem_ctx, operation, e0, e1);
- if (last) {
- last = new(mem_ctx) ir_expression(join_op, last, result);
+ if (cmp) {
+ cmp = new(mem_ctx) ir_expression(join_op, cmp, result);
} else {
- last = result;
+ cmp = result;
}
}
- return last;
+ break;
}
case GLSL_TYPE_ERROR:
/* I assume a comparison of a struct containing a sampler just
* ignores the sampler present in the type.
*/
- return new(mem_ctx) ir_constant(true);
+ break;
+
+ default:
+ assert(!"Should not get here.");
+ break;
}
- return NULL;
+ if (cmp == NULL)
+ cmp = new(mem_ctx) ir_constant(true);
+
+ return cmp;
}
ir_rvalue *
result = do_comparison(ctx, operations[this->oper], op[0], op[1]);
type = glsl_type::bool_type;
- assert(result->type == glsl_type::bool_type);
+ assert(error_emitted || (result->type == glsl_type::bool_type));
break;
case ast_bit_and: