Message ID | 20230517005256.1718424-1-apinski@marvell.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp795343vqo; Tue, 16 May 2023 17:54:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FSCUQ2AD5pDF1JhvQYf2Q6KbthdvRy3sdJRjMwxMfmo3es9bnNFErkiJ0eTqdW+UBkyai X-Received: by 2002:a05:6402:354e:b0:50b:c350:f9ca with SMTP id f14-20020a056402354e00b0050bc350f9camr400131edd.10.1684284852002; Tue, 16 May 2023 17:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684284851; cv=none; d=google.com; s=arc-20160816; b=TMmGOJ4qc9XUvqW+PWDrx9IB0VMU98eU8nC1eK07mmoG8Y/P17LIQagsDQQ/tI7Vi7 2BgtiH2clP9mQho3AzQPaUZ0pJuJVmHx3Rf+xpwq5dHsjoSBVQfAANSBSqQS0pxzkJnZ QSWnSNHg1q31tCtcXjwKQXD66NSi0w15CclPbVJL+AqiQMHI7Dby6zMM8NdHk0T+7sXE 6IIr4mkii/xT3eDykb3Lco7mlcZV5t3Lw1T1LvLOfARKGY7akYzXKRqjtRtkMtL8a1bu hFAwyD4tBYW4dwvnnnYVO0AOK7TG4xj/00/IuvtJ3Gf/fsNd769ns//g5M/33KQirLCn CFUQ== 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=vkk2QLz95b6m8jaFxQvRsMNAVlWLk0zQUy0CVCkuKuQ=; b=DaqdpqbMx8KnCPHupJakVHSArTnyC89G+fe82AAGl09uTO0JU8HAnzxxiKAs/8kI4n TNlRFogCPGqAE5C4ax9VtqHDYTXDftnCJbvZF19lNFBzB/aiEamyV+9TVPQKitc77eYA 8rPaD/EUVroR0yN2v1JiwiWJz1sz/ksrGajHl2MkDSO4MWm/vI4Dt66XcFP6XuK7HT/A r0sjx2WdABTUTE3HwvL9nXqKVVFqihdXsbwmB8nxqk+P44BTyc6pk2lkGwJYsumde2yS 872h5lZkm8+gkMSNmqId0SKbMiAG8JYuC4SJF4A+wpN052r2VF4fGtvxCwEZaj0XYzYt OOHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=k4lJhuny; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l24-20020a056402029800b005069eb56369si6359251edv.596.2023.05.16.17.54.11 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 17:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=k4lJhuny; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 EDB113858C41 for <ouuuleilei@gmail.com>; Wed, 17 May 2023 00:54:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDB113858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684284844; bh=vkk2QLz95b6m8jaFxQvRsMNAVlWLk0zQUy0CVCkuKuQ=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=k4lJhuny2Az7OMFDpI2+GDhTNi+YT/uNVyftsVkJw+TDlz/oBt2aMbDjoljHvyQDU lEiEhl13rKDFu8vb9v4PUR/QlNqmCGD2OVdr1LoKCrwPBrSzLnc9qoaCcXlJbfxbv7 lPGlXTJs/TtEQhuD9CQ4gA1ceQYW3e1fdsMzcsos= 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 47E9A385483A for <gcc-patches@gcc.gnu.org>; Wed, 17 May 2023 00:53:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 47E9A385483A 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 34GNFGpa002154 for <gcc-patches@gcc.gnu.org>; Tue, 16 May 2023 17:53:09 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qja2juj13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Tue, 16 May 2023 17:53:09 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 16 May 2023 17:53:07 -0700 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.48 via Frontend Transport; Tue, 16 May 2023 17:53:07 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id C630A3F70BB; Tue, 16 May 2023 17:53:06 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> CC: Andrew Pinski <apinski@marvell.com> Subject: [PATCH] Fix PR 106900: array-bounds warning inside simplify_builtin_call Date: Tue, 16 May 2023 17:52:56 -0700 Message-ID: <20230517005256.1718424-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: O4kMccLmryDqv50W7fBjQm5XmufuSu-p X-Proofpoint-ORIG-GUID: O4kMccLmryDqv50W7fBjQm5XmufuSu-p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-16_14,2023-05-16_01,2023-02-09_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, T_SCC_BODY_TEXT_LINE 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766100672818984554?= X-GMAIL-MSGID: =?utf-8?q?1766100672818984554?= |
Series |
Fix PR 106900: array-bounds warning inside simplify_builtin_call
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Andrew Pinski
May 17, 2023, 12:52 a.m. UTC
The problem here is that VRP cannot figure out isize could not be 0 due to using integer_zerop. This patch removes the use of integer_zerop and instead checks for 0 directly after converting the tree to an unsigned HOST_WIDE_INT. This allows VRP to figure out isize is not 0 and `isize - 1` will always be >= 0. This patch is just to avoid the warning that GCC could produce sometimes and does not change any code generation or even VRP. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-forwprop.cc (simplify_builtin_call): Check against 0 instead of calling integer_zerop. --- gcc/tree-ssa-forwprop.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Wed, May 17, 2023 at 2:54 AM Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > The problem here is that VRP cannot figure out isize could not be 0 > due to using integer_zerop. This patch removes the use of integer_zerop > and instead checks for 0 directly after converting the tree to > an unsigned HOST_WIDE_INT. This allows VRP to figure out isize is not 0 > and `isize - 1` will always be >= 0. > > This patch is just to avoid the warning that GCC could produce sometimes > and does not change any code generation or even VRP. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. Richard. > gcc/ChangeLog: > > * tree-ssa-forwprop.cc (simplify_builtin_call): Check > against 0 instead of calling integer_zerop. > --- > gcc/tree-ssa-forwprop.cc | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc > index 06f19868ade..0326e6733e8 100644 > --- a/gcc/tree-ssa-forwprop.cc > +++ b/gcc/tree-ssa-forwprop.cc > @@ -1231,14 +1231,14 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) > tree size = gimple_call_arg (stmt2, 2); > /* Size must be a constant which is <= UNITS_PER_WORD and > <= the string length. */ > - if (TREE_CODE (size) != INTEGER_CST || integer_zerop (size)) > + if (TREE_CODE (size) != INTEGER_CST) > break; > > if (!tree_fits_uhwi_p (size)) > break; > > unsigned HOST_WIDE_INT sz = tree_to_uhwi (size); > - if (sz > UNITS_PER_WORD || sz >= slen) > + if (sz == 0 || sz > UNITS_PER_WORD || sz >= slen) > break; > > tree ch = gimple_call_arg (stmt2, 1); > -- > 2.31.1 >
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 06f19868ade..0326e6733e8 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -1231,14 +1231,14 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) tree size = gimple_call_arg (stmt2, 2); /* Size must be a constant which is <= UNITS_PER_WORD and <= the string length. */ - if (TREE_CODE (size) != INTEGER_CST || integer_zerop (size)) + if (TREE_CODE (size) != INTEGER_CST) break; if (!tree_fits_uhwi_p (size)) break; unsigned HOST_WIDE_INT sz = tree_to_uhwi (size); - if (sz > UNITS_PER_WORD || sz >= slen) + if (sz == 0 || sz > UNITS_PER_WORD || sz >= slen) break; tree ch = gimple_call_arg (stmt2, 1);