[Mesa-dev] [PATCH] ir_to_mesa: Skip useless comparison instructions.

Marek Olšák maraeo at gmail.com
Wed Dec 16 03:54:18 PST 2015


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Mon, Dec 7, 2015 at 7:50 PM, Matt Turner <mattst88 at gmail.com> wrote:
> ---
> With this, we generate the same number of Mesa IR instructions before
> and after my series. all() is the same as well.
>
>  src/mesa/program/ir_to_mesa.cpp | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 8160f8e..852655d 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -1113,7 +1113,13 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
>        if (ir->operands[0]->type->is_vector() ||
>           ir->operands[1]->type->is_vector()) {
>          src_reg temp = get_temp(glsl_type::vec4_type);
> -        emit(ir, OPCODE_SNE, dst_reg(temp), op[0], op[1]);
> +         if (ir->operands[0]->type->is_boolean() &&
> +             ir->operands[1]->as_constant() &&
> +             ir->operands[1]->as_constant()->is_zero()) {
> +            temp = op[0];
> +         } else {
> +            emit(ir, OPCODE_SNE, dst_reg(temp), op[0], op[1]);
> +         }
>
>          /* After the dot-product, the value will be an integer on the
>           * range [0,4].  Zero stays zero, and positive values become 1.0.
> --
> 2.4.9
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list