On Wed, 1 Mar 2023, Jakub Jelinek wrote:

> Hi!
> 
> When these tree codes were introduced, expand_debug_expr hasn't been
> updated to handle them.  For the VEC_*_EXPR we currently mostly punt, the
> non-vector ones can be handled easily.  In release compilers this doesn't
> ICE, but with checking we ICE so that we make sure to handle all the needed
> tree codes there.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested
> on the testcase with cross to aarch64-linux, ok for trunk?

OK.

> 2023-03-01  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR debug/108967
>       * cfgexpand.cc (expand_debug_expr): Handle WIDEN_{PLUS,MINUS}_EXPR
>       and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR.
> 
>       * g++.dg/debug/pr108967.C: New test.
> 
> --- gcc/cfgexpand.cc.jj       2023-02-21 11:44:48.479464567 +0100
> +++ gcc/cfgexpand.cc  2023-02-28 16:21:45.068784055 +0100
> @@ -5365,6 +5365,10 @@ expand_debug_expr (tree exp)
>      case VEC_WIDEN_MULT_ODD_EXPR:
>      case VEC_WIDEN_LSHIFT_HI_EXPR:
>      case VEC_WIDEN_LSHIFT_LO_EXPR:
> +    case VEC_WIDEN_PLUS_HI_EXPR:
> +    case VEC_WIDEN_PLUS_LO_EXPR:
> +    case VEC_WIDEN_MINUS_HI_EXPR:
> +    case VEC_WIDEN_MINUS_LO_EXPR:
>      case VEC_PERM_EXPR:
>      case VEC_DUPLICATE_EXPR:
>      case VEC_SERIES_EXPR:
> @@ -5401,6 +5405,8 @@ expand_debug_expr (tree exp)
>      case WIDEN_MULT_EXPR:
>      case WIDEN_MULT_PLUS_EXPR:
>      case WIDEN_MULT_MINUS_EXPR:
> +    case WIDEN_PLUS_EXPR:
> +    case WIDEN_MINUS_EXPR:
>        if (SCALAR_INT_MODE_P (GET_MODE (op0))
>         && SCALAR_INT_MODE_P (mode))
>       {
> @@ -5413,6 +5419,10 @@ expand_debug_expr (tree exp)
>           op1 = simplify_gen_unary (ZERO_EXTEND, mode, op1, inner_mode);
>         else
>           op1 = simplify_gen_unary (SIGN_EXTEND, mode, op1, inner_mode);
> +       if (TREE_CODE (exp) == WIDEN_PLUS_EXPR)
> +         return simplify_gen_binary (PLUS, mode, op0, op1);
> +       else if (TREE_CODE (exp) == WIDEN_MINUS_EXPR)
> +         return simplify_gen_binary (MINUS, mode, op0, op1);
>         op0 = simplify_gen_binary (MULT, mode, op0, op1);
>         if (TREE_CODE (exp) == WIDEN_MULT_EXPR)
>           return op0;
> --- gcc/testsuite/g++.dg/debug/pr108967.C.jj  2023-02-28 17:27:27.922636974 
> +0100
> +++ gcc/testsuite/g++.dg/debug/pr108967.C     2023-02-28 17:27:20.571741186 
> +0100
> @@ -0,0 +1,41 @@
> +// PR debug/108967
> +// { dg-do compile }
> +
> +struct F { unsigned short r[8]; };
> +extern void foo (F);
> +
> +static inline F
> +bar (F a, F b)
> +{
> +  for (int i = 0; i < 8; ++i)
> +    a.r[i] = a.r[i] + b.r[i] < (unsigned short) -1 ? a.r[i] + b.r[i] : 
> (unsigned short) -1;
> +  return a;
> +}
> +
> +static inline void
> +baz (F v)
> +{
> +  foo (v);
> +}
> +
> +void
> +qux (F a, F b)
> +{
> +  F c = bar (a, b);
> +  baz (c);
> +}
> +
> +static inline F
> +corge (F a, F b)
> +{
> +  for (int i = 0; i < 8; ++i)
> +    a.r[i] = a.r[i] - b.r[i] > 0 ? a.r[i] - b.r[i] : 0;
> +  return a;
> +}
> +
> +void
> +garply (F a, F b)
> +{
> +  F c = corge (a, b);
> +  baz (c);
> +}
> 
>       Jakub
> 
> 

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

Reply via email to