Message ID | 1667425595-2654-3-git-send-email-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:a5d:6687:0:0:0:0:0 with SMTP id l7csp159314wru; Wed, 2 Nov 2022 14:48:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Vldk1mfX7wezTkZ4EW6NDhm/TyuIvkm2rfhdOZBj8xJ3bPFeU5ia9kTZGmUeePhymUv0x X-Received: by 2002:a05:6402:3896:b0:45c:93c3:3569 with SMTP id fd22-20020a056402389600b0045c93c33569mr27314627edb.37.1667425731696; Wed, 02 Nov 2022 14:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667425731; cv=none; d=google.com; s=arc-20160816; b=vEle+6taZIF9plpAFq4CKwSLZVUGxKAxSsCx/pbSDY3Ypq0iuRFYGoW//8BVeIV6aL aPZjXiU+wHVKfMUJm8PcH2Q+Kr26oAA3kxyjTyzg9Hl/AhHuyiAMtkCTsx1ZcyrxBCvt UGF0n0ng4GnBSpTXMnCugH8MUzNf5zOIwf6qyVM5ZP9nd19PVXnbxnaM3xzUJUkdELTI FQNAqp2cGmkwmnPKWKSP/JnQxvyLkx6Ro4285gSIj48RbmgP600u29d4lDLb38HzKxji ft5NBarX2kb1PWAGvOiXDlw2V6Loce3u/wazWxGp5eewpbI4WBVVAcdZ27Be6ABZ1guK sasQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=StuS/AKSCLpkjdSpzzBHMdOQajNW7R9lxDmm2ogfSJE=; b=bXOjXX9zjOL0Fl7iENrxl5W3pJ1PkXRO1sxzdwdRxsJTmcjSTPY7fHYwfB5Y7ftsOa WbwVMazF6Ksss5RNCWUUuPceuODDtyhHkmZs3k3bFCNEFuOldsbgmAto5E4WFelIKS5N XRMiIBUJgBl1ILCzSgAWd1s/lm49uNhcPlejdlJC9Fda5dyJdi14M0xIUs112XWajwgM PyZ14G0pH/hrac5v8inJHMpIV5G+DJnChjXRf9jYimw7ucCltYbqo/tWZCBbJgvYgdFl SQMjLI10GLKH0kqvFZtJI/aSuK+JK+RaVt0QAZkdK3K6BkDUG+wQWYF5C5Q6DU9DGkxq MAAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Apqfr+vX; 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 t16-20020a056402241000b004534c7d4ebfsi17221620eda.434.2022.11.02.14.48.51 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 14:48:51 -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=Apqfr+vX; 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 C3FB53856969 for <ouuuleilei@gmail.com>; Wed, 2 Nov 2022 21:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3FB53856969 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667425706; 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=Apqfr+vXlvn9uKfhRD5Tu7XHhLxwIdtD5ysfXzGUppzjuEBVWzBsqJYFJd1cD64AK 8BBRvnOmRNHruoZq5WMHv+Zd39IAivKxdz0F/rhW7n6Wic5X4p7QOU5Hd7TbDT1MsI egt7heUDyM599XTuU9FyK3bhyrKs6t+zeGV4RWhM= 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+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?1748422604163591837?= X-GMAIL-MSGID: =?utf-8?q?1748422604163591837?= |
Series |
tree_nonzero_bits vs vector and complex types
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
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: