[Mesa-dev] [PATCH] i965/fs: Drop no-op shifts by 0.
Matt Turner
mattst88 at gmail.com
Thu Oct 24 19:27:42 CEST 2013
On Thu, Oct 24, 2013 at 8:53 AM, Eric Anholt <eric at anholt.net> wrote:
> I noticed this in a shader in Unigine Heaven that was spilling. While it
> doesn't really reduce register pressure, it shaves a few instructions
> anyway (7955 -> 7882).
> ---
> src/glsl/opt_algebraic.cpp | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index 37b2f02..ff06cfc 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -387,6 +387,14 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
> }
> break;
>
> + case ir_binop_rshift:
> + case ir_binop_lshift:
> + if (is_vec_zero(op_const[0]))
> + return ir->operands[1];
> + else if (is_vec_zero(op_const[1]))
> + return ir->operands[0];
> + break;
> +
> case ir_binop_logic_and:
> /* FINISHME: Also simplify (a && a) to (a). */
> if (is_vec_one(op_const[0])) {
> --
> 1.8.4.rc3
Prefix should be glsl:, but other than that
Reviewed-by: Matt Turner <mattst88 at gmail.com>
More information about the mesa-dev
mailing list