From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 5F4743858D20 for ; Wed, 8 Feb 2023 21:14:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F4743858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 318IcDjo024968 for ; Wed, 8 Feb 2023 13:14:28 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=UhcVUe/EC/b6aAPO+BuyFJFTs/5OulbuFv7/tEyLBKg=; b=WG+lw+UCzM5nKyfPvPExN2H9RFQRdDU5498l9m0E13RSwxL4z17JchO0ALBWEUYyIhC0 +BBjRpF2j9+5Olkr9g5b4hJDIC1gmlJGQ/6amhkkTHxBAtvRMQHAJtcTPrxJI+GpIY3G ocZwJDP8rlS+RScSV5gLAjuam7cTHCLGEBtsSnFknVHHPF/zBQdvDX7RVc8UE0bkJTB6 KRfEFnGnN1VX+JSVSoCIzsTbo/K7aVsp4yyf+Jdt4Kz/hAVCB2bguP6m7GfW2fjPIOpw MmabRL8dEDavcjDLv+3YLjPFyJGiUu+E5CUTN+0SpJw7/ZcN6JQoZm9w4D8FJXx2C656 8g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nm65kwsg5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 08 Feb 2023 13:14:28 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 8 Feb 2023 13:14:26 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Wed, 8 Feb 2023 13:14:26 -0800 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.67]) by maili.marvell.com (Postfix) with ESMTP id 626813F7097; Wed, 8 Feb 2023 13:14:26 -0800 (PST) From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] When simplifing BFR of an insert, require a mode precision integral type (PR108688) Date: Wed, 8 Feb 2023 13:14:19 -0800 Message-ID: <20230208211419.1583473-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: sDpebX9ODsazsOgGt-Zw5d3EQN0D_xGt X-Proofpoint-ORIG-GUID: sDpebX9ODsazsOgGt-Zw5d3EQN0D_xGt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-08_09,2023-02-08_02,2022-06-22_01 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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: The same problem as PR 88739 has crept in but this time in match.pd when simplifying bit_field_ref of an bit_insert. That is we are generating a BIT_FIELD_REF of a non-mode-precision integral type. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/108688 gcc/ChangeLog: * match.pd (bit_field_ref [bit_insert]): Avoid generating BIT_FIELD_REFs of non-mode-precision integral operands gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr108688-1.c: New test. --- gcc/match.pd | 4 +++- gcc/testsuite/gcc.c-torture/compile/pr108688-1.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr108688-1.c diff --git a/gcc/match.pd b/gcc/match.pd index c9e8bebede2..d8353072822 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7487,7 +7487,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) isize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (@1))); } (switch - (if (wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos)) + (if ((!INTEGRAL_TYPE_P (TREE_TYPE (@1)) + || type_has_mode_precision_p (TREE_TYPE (@1))) + && wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos)) && wi::leu_p (wi::to_wide (@rpos) + wi::to_wide (@rsize), wi::to_wide (@ipos) + isize)) (BIT_FIELD_REF @1 @rsize { wide_int_to_tree (bitsizetype, diff --git a/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c new file mode 100644 index 00000000000..43d782d62bd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c @@ -0,0 +1,15 @@ + + +union U { signed int d : 7; signed int e : 2; } u; +int a, b; + +void +foo (void) +{ + for (int i = 0; i < 64; i++) + { + u.d = a; + u.e ^= b; + } +} + -- 2.17.1