[Mesa-dev] [PATCH 2/7] glsl: Fix assertion checking types of constant bitshift expressions.

Kenneth Graunke kenneth at whitecape.org
Wed Sep 28 01:11:53 PDT 2011


On 09/27/2011 03:08 PM, Eric Anholt wrote:
> Bitshifts are one of the rare places that GLSL allows mixed base types
> without an implicit conversion occurring.
> ---
>  src/glsl/ir_constant_expression.cpp |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
> index f0299a2..56a4237 100644
> --- a/src/glsl/ir_constant_expression.cpp
> +++ b/src/glsl/ir_constant_expression.cpp
> @@ -69,7 +69,9 @@ ir_expression::constant_expression_value()
>     }
>  
>     if (op[1] != NULL)
> -      assert(op[0]->type->base_type == op[1]->type->base_type);
> +      assert(op[0]->type->base_type == op[1]->type->base_type ||
> +	     this->operation == ir_binop_lshift ||
> +	     this->operation == ir_binop_rshift);
>  
>     bool op0_scalar = op[0]->type->is_scalar();
>     bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar();

It seems weird that we allow this in the IR for shifts, but for nothing
else.  I'm pretty sure that -all- other binary operations require their
operand types to be equal.  Might be more consistent to make AST->HIR
generate i2u or u2i nodes to convert op[1] to op[0]'s type.

Though, those are silly, and this ought to work fine too.

Certainly the existing code is broken, your new code is not broken, and
ir_validate allows mixed types in the IR.  *shrug*

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list