[Mesa-dev] [PATCH] radeonsi: fix a regression in si_eliminate_const_output

Marek Olšák maraeo at gmail.com
Thu Oct 20 12:35:57 UTC 2016


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

Is there a way to fold all constant expressions somehow?

Marek

On Thu, Oct 20, 2016 at 1:09 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> A constant value of float type is not necessarily a ConstantFP: it could also
> be a constant expression that for some reason hasn't been folded.
>
> This fixes a regression in GL45-CTS.arrays_of_arrays_gl.InteractionFunctionCalls2
> that was introduced by commit 3ec9975555d1cc5365413ad9062f412904f944a3.
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index 3a84253..5eebf29 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -6528,37 +6528,36 @@ static bool si_eliminate_const_output(struct si_shader_context *ctx,
>                                       LLVMValueRef inst, unsigned offset)
>  {
>         struct si_shader *shader = ctx->shader;
>         unsigned num_outputs = shader->selector->info.num_outputs;
>         unsigned i, default_val; /* SPI_PS_INPUT_CNTL_i.DEFAULT_VAL */
>         bool is_zero[4] = {}, is_one[4] = {};
>
>         for (i = 0; i < 4; i++) {
>                 LLVMBool loses_info;
>                 LLVMValueRef p = LLVMGetOperand(inst, 5 + i);
> -               if (!LLVMIsConstant(p))
> -                       return false;
>
>                 /* It's a constant expression. Undef outputs are eliminated too. */
>                 if (LLVMIsUndef(p)) {
>                         is_zero[i] = true;
>                         is_one[i] = true;
> -               } else {
> +               } else if (LLVMIsAConstantFP(p)) {
>                         double a = LLVMConstRealGetDouble(p, &loses_info);
>
>                         if (a == 0)
>                                 is_zero[i] = true;
>                         else if (a == 1)
>                                 is_one[i] = true;
>                         else
>                                 return false; /* other constant */
> -               }
> +               } else
> +                       return false;
>         }
>
>         /* Only certain combinations of 0 and 1 can be eliminated. */
>         if (is_zero[0] && is_zero[1] && is_zero[2])
>                 default_val = is_zero[3] ? 0 : 1;
>         else if (is_one[0] && is_one[1] && is_one[2])
>                 default_val = is_zero[3] ? 2 : 3;
>         else
>                 return false;
>
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list