From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 51FE53857C71 for ; Mon, 23 Oct 2023 13:32:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 51FE53857C71 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 51FE53857C71 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698067951; cv=none; b=lHMd9XptVnKQav38SHRUAzJhpyWrTd+rtjRQF38YUUSk8LjyczyHaznLut7Xwi5i6+SsSTKL1WG9hMuOXK6XGdGcG9/p6cxP29rzHdQwYPwvsGkA8Vkw9+GFCtPPrYwXC5uKEnRsAgUGXqqtqB0uHC+OynQ5r/n1Oul1A+8OELg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698067951; c=relaxed/simple; bh=Ok5SHkm2TIkuB6JM1BB9DyMGXRBukQIxG1sVloywMqo=; h=Date:From:To:Subject:MIME-Version; b=uxAfBNHsmuRELoatgOTdKfUHCiGBztoJsuT1X1hWeg8MSoVAlbEvi35f4lXE+WPy37wXezKEeX5UeyZrgYZicK7r9gXSlvwwQAnRynVWmQduUb0fNZDaUK8Sjg8KeU+DudUGDex1k5tVkwCd055wxRX9ewB2YWUVnzJNv1MVGPw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3DBB021846 for ; Mon, 23 Oct 2023 13:32:29 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 01EA52C8CD for ; Mon, 23 Oct 2023 13:32:29 +0000 (UTC) Date: Mon, 23 Oct 2023 13:32:29 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/111916 - SRA of BIT_FIELD_REF of constant pool entries User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [-0.01 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[149.44.160.134:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; R_SPF_SOFTFAIL(0.60)[~all:c]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; VIOLATED_DIRECT_SPF(3.50)[]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_NA(0.20)[suse.de]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -0.01 X-Rspamd-Queue-Id: 3DBB021846 X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20231023133229.9E-OA_Ro9QcKecMwXLyN4-SM3Hqvr8bo9XLxD3Oscs0@z> The following adjusts a leftover BIT_FIELD_REF special-casing to only cover the cases general code doesn't handle. Boostrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/111916 * tree-sra.cc (sra_modify_assign): Do not lower all BIT_FIELD_REF reads that are sra_handled_bf_read_p. * gcc.dg/torture/pr111916.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr111916.c | 16 ++++++++++++++++ gcc/tree-sra.cc | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr111916.c diff --git a/gcc/testsuite/gcc.dg/torture/pr111916.c b/gcc/testsuite/gcc.dg/torture/pr111916.c new file mode 100644 index 00000000000..2873045aaa4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr111916.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +#pragma pack(1) +struct A { + int b : 4; + int c : 11; + int d : 2; + int e : 5; +} f; +int main() +{ + struct A g = {1, 1, 1, 1}; + while (!g.b) + f = g; + return 0; +} diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc index f8dff8b27d7..b985dee6964 100644 --- a/gcc/tree-sra.cc +++ b/gcc/tree-sra.cc @@ -4275,7 +4275,8 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi) if (TREE_CODE (rhs) == REALPART_EXPR || TREE_CODE (lhs) == REALPART_EXPR || TREE_CODE (rhs) == IMAGPART_EXPR || TREE_CODE (lhs) == IMAGPART_EXPR - || TREE_CODE (rhs) == BIT_FIELD_REF || TREE_CODE (lhs) == BIT_FIELD_REF) + || (TREE_CODE (rhs) == BIT_FIELD_REF && !sra_handled_bf_read_p (rhs)) + || TREE_CODE (lhs) == BIT_FIELD_REF) { modify_this_stmt = sra_modify_expr (gimple_assign_rhs1_ptr (stmt), gsi, false); -- 2.35.3