From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id C4A9C3858D33; Wed, 1 Mar 2023 09:27:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4A9C3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677662846; bh=7Xa2MXLgrcjqOQe07hJR/8Xqbkh5I+pwVNyUeBHRSKM=; h=From:To:Subject:Date:From; b=auZ1IpRsxpP25jh13CIpqJTP8rmMHYr9pUw3vQ73XcnytqqsQKs6i/CyQSVbbnk8t G/19K0wTAqo9of0++2k0zagOgQiQwIc4WO6ey90JbIzeG1tUUHFVa0yDlH6rSKBHFA QFeDOLOl2Uh/GK76fQe/FBdBPc0Vl1XHX7hkIXWo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6388] cfgexpand: Handle WIDEN_{PLUS, MINUS}_EXPR and VEC_WIDEN_{PLUS, MINUS}_{HI, LO}_EXPR in expand_debug_ex X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: b222e725f53231a0bd9799ca93892a79d592a5f3 X-Git-Newrev: 520403f324a6ed8b527f39239709dd0841b992e2 Message-Id: <20230301092726.C4A9C3858D33@sourceware.org> Date: Wed, 1 Mar 2023 09:27:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:520403f324a6ed8b527f39239709dd0841b992e2 commit r13-6388-g520403f324a6ed8b527f39239709dd0841b992e2 Author: Jakub Jelinek Date: Wed Mar 1 10:26:46 2023 +0100 cfgexpand: Handle WIDEN_{PLUS,MINUS}_EXPR and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR in expand_debug_expr [PR108967] 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. 2023-03-01 Jakub Jelinek 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. Diff: --- gcc/cfgexpand.cc | 10 +++++++++ gcc/testsuite/g++.dg/debug/pr108967.C | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index 25b1558dcb9..1a1b26b1c6c 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -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; diff --git a/gcc/testsuite/g++.dg/debug/pr108967.C b/gcc/testsuite/g++.dg/debug/pr108967.C new file mode 100644 index 00000000000..b50dadc5925 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr108967.C @@ -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); +}