Message ID | 1667425595-2654-3-git-send-email-apinski@marvell.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4014D3858436 for <patchwork@sourceware.org>; Wed, 2 Nov 2022 21:48:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4014D3858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667425692; bh=StuS/AKSCLpkjdSpzzBHMdOQajNW7R9lxDmm2ogfSJE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=sZnyRzZvCYyE0YatiAtymOe3cEsDlnSXYJUfighw9LnW0Un/E21TfuBVG+w5PodI1 Dd4x7hdj46ceWDqytA39NZIa+EKqec4H0YNRf0/2Flbg9/86asgMYzxv5Ffv856M7D s/AiuwDu3C7crF7IEEtrDTYYYAW19b91vuUvYJ/Q= 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 5B9DB3857356 for <gcc-patches@gcc.gnu.org>; Wed, 2 Nov 2022 21:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B9DB3857356 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 2A2Hbe6s027052 for <gcc-patches@gcc.gnu.org>; Wed, 2 Nov 2022 14:46:43 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kkw3y0w5s-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Wed, 02 Nov 2022 14:46:42 -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.18; Wed, 2 Nov 2022 14:46:40 -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.2 via Frontend Transport; Wed, 2 Nov 2022 14:46:40 -0700 Received: from linux.marvell.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 771D53F7066; Wed, 2 Nov 2022 14:46:40 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> Subject: [PATCH 2/2] Add assert for type on tree_nonzero_bits Date: Wed, 2 Nov 2022 14:46:35 -0700 Message-ID: <1667425595-2654-3-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1667425595-2654-1-git-send-email-apinski@marvell.com> References: <1667425595-2654-1-git-send-email-apinski@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: FuUSulIoqxxfBzSbBCaoK7KvdYSLSK6F X-Proofpoint-ORIG-GUID: FuUSulIoqxxfBzSbBCaoK7KvdYSLSK6F X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-02_15,2022-11-02_01,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 <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: apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: apinski@marvell.com Cc: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
tree_nonzero_bits vs vector and complex types
|
|
Commit Message
Li, Pan2 via Gcc-patches
Nov. 2, 2022, 9:46 p.m. UTC
From: Andrew Pinski <apinski@marvell.com>
Right now anyone could call tree_nonzero_bits with
either complex or vector types and this will return
the wrong thing. So just assert that nobody calls
it with this.
OK? Bootstrapped and tested with no regressions on x86_64-linux-gnu.
gcc/ChangeLog:
* fold-const.cc (tree_nonzero_bits): Add
assert.
---
gcc/fold-const.cc | 3 +++
1 file changed, 3 insertions(+)
Comments
On Wed, Nov 2, 2022 at 10:48 PM apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > From: Andrew Pinski <apinski@marvell.com> > > Right now anyone could call tree_nonzero_bits with > either complex or vector types and this will return > the wrong thing. So just assert that nobody calls > it with this. > > OK? Bootstrapped and tested with no regressions on x86_64-linux-gnu. The function comment needs adjustment. To me, nonzero bits of a v4si would simply include all bits of v4si - isn't that what happens? I see the SSA get_nonzero_bits uses element_precision but tree_nonzero_bits uses TYPE_PRECISON as fallback, so I guess the assert is correct. Still the function comment should be amended, also ... > gcc/ChangeLog: > > * fold-const.cc (tree_nonzero_bits): Add > assert. > --- > gcc/fold-const.cc | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc > index 7e1ea58518b..3ccac9b28df 100644 > --- a/gcc/fold-const.cc > +++ b/gcc/fold-const.cc > @@ -16567,6 +16567,9 @@ c_getstr (tree str) > wide_int > tree_nonzero_bits (const_tree t) > { > + gcc_assert (TREE_CODE (TREE_TYPE (t)) != VECTOR_TYPE > + && TREE_CODE (TREE_TYPE (t)) != COMPLEX_TYPE); ... please perform a "positive" test. Like INTEGRAL_TYPE_P (TREE_TYPE (t)) || POINTER_TYPE_P (TREE_TYPE (t)) Richard. > + > switch (TREE_CODE (t)) > { > case INTEGER_CST: > -- > 2.17.1 >
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 7e1ea58518b..3ccac9b28df 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -16567,6 +16567,9 @@ c_getstr (tree str) wide_int tree_nonzero_bits (const_tree t) { + gcc_assert (TREE_CODE (TREE_TYPE (t)) != VECTOR_TYPE + && TREE_CODE (TREE_TYPE (t)) != COMPLEX_TYPE); + switch (TREE_CODE (t)) { case INTEGER_CST: