From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id BB71C3858409; Wed, 17 Jan 2024 12:57:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB71C3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705496263; bh=VXhINKRppXNGPKKi+noo5HZHvGQZMcEfJuzBmROkj6U=; h=From:To:Subject:Date:From; b=XR/o4Tc/A2aMuwI9MUjfFnAcvx/r0xl+qxSda9b5oTM1mX5NcDSqalFrjcp9YF4vh onWWy5QCQdEeqxmoGitBZZUWLxyAGIB/c+wmjSxFdJqzAas3rGTV0n/CCFmGD4A8p6 W/rGEV78DZf0cEeim1bVX32hv0goB/RRzMM1Upro= 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 r14-8184] lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 2c74d5c0a0f21ae1d0c195ca0d81a3d1032f27e3 X-Git-Newrev: 2fb78d431ff3c05997ef31837d6eb319d84a4239 Message-Id: <20240117125743.BB71C3858409@sourceware.org> Date: Wed, 17 Jan 2024 12:57:43 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2fb78d431ff3c05997ef31837d6eb319d84a4239 commit r14-8184-g2fb78d431ff3c05997ef31837d6eb319d84a4239 Author: Jakub Jelinek Date: Wed Jan 17 13:55:50 2024 +0100 lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408] Unlike NOP_EXPR/CONVERT_EXPR which are GIMPLE_UNARY_RHS, VIEW_CONVERT_EXPR is GIMPLE_SINGLE_RHS and so gimple_assign_rhs1 contains the operand wrapped in VIEW_CONVERT_EXPR tree. So, to handle it like other casts we need to look through it. 2024-01-17 Jakub Jelinek PR tree-optimization/113408 * gimple-lower-bitint.cc (bitint_large_huge::handle_stmt): For VIEW_CONVERT_EXPR, pass TREE_OPERAND (rhs1, 0) rather than rhs1 to handle_cast. * gcc.dg/bitint-71.c: New test. Diff: --- gcc/gimple-lower-bitint.cc | 5 ++++- gcc/testsuite/gcc.dg/bitint-71.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index 672a9a33751..d3d113578d9 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -1975,9 +1975,12 @@ bitint_large_huge::handle_stmt (gimple *stmt, tree idx) case INTEGER_CST: return handle_operand (gimple_assign_rhs1 (stmt), idx); CASE_CONVERT: - case VIEW_CONVERT_EXPR: return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt), idx); + case VIEW_CONVERT_EXPR: + return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)), + TREE_OPERAND (gimple_assign_rhs1 (stmt), 0), + idx); default: break; } diff --git a/gcc/testsuite/gcc.dg/bitint-71.c b/gcc/testsuite/gcc.dg/bitint-71.c new file mode 100644 index 00000000000..f7ff8716f36 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitint-71.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/113408 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23 -O2" } */ + +#if __BITINT_MAXWIDTH__ >= 713 +struct A { _BitInt(713) b; } g; +#else +struct A { _BitInt(49) b; } g; +#endif +int f; + +void +foo (void) +{ + struct A j = g; + if (j.b) + f = 0; +}