From patchwork Wed Feb 8 21:14:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 54619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3691060wrn; Wed, 8 Feb 2023 13:15:25 -0800 (PST) X-Google-Smtp-Source: AK7set/m3Lrtwt5fjv5j1WjVVZFAkU/GVDSUT9tejbkBLWex+yL0BjMu4QGsrJix4qW80YrBzX6b X-Received: by 2002:a17:906:1182:b0:86f:e30c:72c1 with SMTP id n2-20020a170906118200b0086fe30c72c1mr8670868eja.8.1675890925846; Wed, 08 Feb 2023 13:15:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675890925; cv=none; d=google.com; s=arc-20160816; b=cOUmfuOlUhwD9i1j8qtdBTBrmJXeqtpLQswIL3YVgB5FVgzLxFXPMkNU1BWaVwTL/y FxfCisZDjXlO+lFHGOwi1dhiShh0Bues2uSgs+wo+w0FmfgPamAf14Z3hKfqiSKpPmit 6QU8An8I8am0AzKm2Zj+g0Tyy3IMD1Bqj24EYsytv5aSSdHf/FKSPYumc9qVyZxyZHto rbovjNBHK9lHVP0TUvG34MbTM3dOSW4+HwYdacPVYJACBhQpxXPJJ2ygSq84L49VyyDf iNFdOjgMPbV8PjQJJ7n4m4opSIUjbq9alFqLwjg5EyBzTnHJX8GWcGIHen9pLal82KF+ +gKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UhcVUe/EC/b6aAPO+BuyFJFTs/5OulbuFv7/tEyLBKg=; b=uHnHVvMBGcl4vEUsL5msxxHhbVbmhkgqT4ExwlSlq+ZrhbchFu0cQn8IPoLq2AK84h iX6EY+px+tkKj8OSH4lOHjmJV+smRwbuN+EkUZUdWR+aUXjm8EerUtf1OmULfBO3odiP U1AEdTh1oiwFE+/r+E1wTEtY77za68hscP8mXQVFT2gMrlVIYoa5f1sdiOnHjoqtH8y6 uaec6Z/xay3GmbASuzZVfaIiIIR2PFVA6yp2h4jQrJKTyeDUAaW1uMfVchxQ6sdk+n4Q ydtvLR2riIT5Ispa8dJ26TEemTYa+R/FI+0+NwopAQk/Ar6mJz3a6Y9nleVvAo8JqgnO ZdfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K+p8rDC2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f5-20020a1709063f4500b0087868ccbcf9si2802911ejj.885.2023.02.08.13.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 13:15:25 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K+p8rDC2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C4603858C53 for ; Wed, 8 Feb 2023 21:15:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C4603858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675890923; bh=UhcVUe/EC/b6aAPO+BuyFJFTs/5OulbuFv7/tEyLBKg=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=K+p8rDC2WJn13m2JoDSkGBNGZ/H41qULxxOXde0qW+kHATmMHy2tPBI3nhTyQjkTe ZUIEcn3i0mDHuqkGyJIEEfL+/JwjFtdmtpyQojtVtEAJQsFOwfixtsu2f/Jjh6a1lZ 2IpjF8Pmc3CJYPG5vKfyMPr+R47tCqUsoTFoIHh4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757299003531953329?= X-GMAIL-MSGID: =?utf-8?q?1757299003531953329?= 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; + } +} +