On Wed, 31 Jan 2024, Jakub Jelinek wrote:

> Hi!
> 
> Yet another spot where we need to treat VIEW_CONVERT_EXPR differently
> from NOP_EXPR/CONVERT_EXPR.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK

> 2024-01-31  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR tree-optimization/113639
>       * gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr):
>       For VIEW_CONVERT_EXPR set rhs1 to its operand.
> 
>       * gcc.dg/bitint-79.c: New test.
> 
> --- gcc/gimple-lower-bitint.cc.jj     2024-01-27 13:06:49.183671155 +0100
> +++ gcc/gimple-lower-bitint.cc        2024-01-30 17:06:56.829144801 +0100
> @@ -2159,6 +2159,8 @@ bitint_large_huge::handle_operand_addr (
>             gcc_assert (gimple_assign_cast_p (g));
>             tree rhs1 = gimple_assign_rhs1 (g);
>             bitint_prec_kind kind = bitint_prec_small;
> +           if (TREE_CODE (rhs1) == VIEW_CONVERT_EXPR)
> +             rhs1 = TREE_OPERAND (rhs1, 0);
>             gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (rhs1)));
>             if (TREE_CODE (TREE_TYPE (rhs1)) == BITINT_TYPE)
>               kind = bitint_precision_kind (TREE_TYPE (rhs1));
> --- gcc/testsuite/gcc.dg/bitint-79.c.jj       2024-01-30 17:18:50.711135054 
> +0100
> +++ gcc/testsuite/gcc.dg/bitint-79.c  2024-01-30 17:18:22.986524397 +0100
> @@ -0,0 +1,16 @@
> +/* PR tree-optimization/113639 */
> +/* { dg-do compile { target bitint } } */
> +/* { dg-options "-O2 -std=c23" } */
> +
> +int j, k;
> +#if __BITINT_MAXWIDTH__ >= 162
> +struct S { _BitInt(162) n; };
> +void bar (_BitInt(162) x);
> +
> +void
> +foo (struct S s)
> +{
> +  bar (s.n * j);
> +  (void) (s.n * k);
> +}
> +#endif
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to