From patchwork Sat Dec 18 06:54:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1570450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha1 header.s=gotplt.org header.b=nWxLKFQl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JGHNX5ZlHz9sXM for ; Sat, 18 Dec 2021 18:22:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3ACD3385842D for ; Sat, 18 Dec 2021 07:21:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id CB4803858D28 for ; Sat, 18 Dec 2021 07:21:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB4803858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7B80B821A83; Sat, 18 Dec 2021 07:21:46 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 048E38219F2; Sat, 18 Dec 2021 07:21:46 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.114.196.210 (trex/6.4.3); Sat, 18 Dec 2021 07:21:46 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Language-Whispering: 7a3b76314c5b9b71_1639812106257_2492408112 X-MC-Loop-Signature: 1639812106257:3975518625 X-MC-Ingress-Time: 1639812106257 Received: from rhbox.redhat.com (unknown [1.6.40.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4JGHN82nQMz30; Fri, 17 Dec 2021 23:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1639812105; bh=lOAeK65eTppiZw+Jj8iQZIzvVxM=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=nWxLKFQlQQB9NJMOifaDXMOS80MNh2FHNSJP6OReGWp8mQ9yQOOqVp87dR9v8qnjF eqCDDIlx+VM/PeVlZA/eGrV6grs/ncSdrIaBbBlS40uRo1G1UkWb0D3fjxDpUaFKup 14YcJHRuQwjQQEo2sNIlPAU2XPUAhkoJZ3b52Rb0= From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH v3] tree-optimization/103759: Use sizetype everywhere for object sizes Date: Sat, 18 Dec 2021 12:24:48 +0530 Message-Id: <20211218065448.121912-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211217214711.GF2646553@tucnak> References: <20211217214711.GF2646553@tucnak> MIME-Version: 1.0 X-Spam-Status: No, score=-3038.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: jakub@redhat.com, dje.gcc@gmail.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Since all computations in tree-object-size are now done in sizetype and not HOST_WIDE_INT, comparisons with HOST_WIDE_INT based unknown and initval would be incorrect. Instead, use the sizetype trees directly to generate and evaluate initval and unknown size values. gcc/ChangeLog: PR tree-optimization/103759 * tree-object-size (unknown, initval): Remove functions. (size_unknown, size_initval, size_unknown_p): Operate directly on trees. Signed-off-by: Siddhesh Poyarekar --- Tested a full bootstrap on x86_64, config=ubsan-bootstrap and i686. Changes from v2: - Operate directly on trees as per Jakub's suggestion. gcc/tree-object-size.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 71f6b747d05..ee9ea1bfbfd 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -83,30 +83,13 @@ static bitmap computed[OST_END]; /* Maximum value of offset we consider to be addition. */ static unsigned HOST_WIDE_INT offset_limit; -/* Initial value of object sizes; zero for maximum and SIZE_MAX for minimum - object size. */ - -static inline unsigned HOST_WIDE_INT -initval (int object_size_type) -{ - return (object_size_type & OST_MINIMUM) ? HOST_WIDE_INT_M1U : 0; -} - -/* Unknown object size value; it's the opposite of initval. */ - -static inline unsigned HOST_WIDE_INT -unknown (int object_size_type) -{ - return ~initval (object_size_type); -} - /* Return true if VAL is represents an unknown size for OBJECT_SIZE_TYPE. */ static inline bool size_unknown_p (tree val, int object_size_type) { - return (tree_fits_uhwi_p (val) - && tree_to_uhwi (val) == unknown (object_size_type)); + return ((object_size_type & OST_MINIMUM) + ? integer_zerop (val) : integer_all_onesp (val)); } /* Return a tree with initial value for OBJECT_SIZE_TYPE. */ @@ -114,7 +97,8 @@ size_unknown_p (tree val, int object_size_type) static inline tree size_initval (int object_size_type) { - return size_int (initval (object_size_type)); + return ((object_size_type & OST_MINIMUM) + ? TYPE_MAX_VALUE (sizetype) : size_zero_node); } /* Return a tree with unknown value for OBJECT_SIZE_TYPE. */ @@ -122,7 +106,8 @@ size_initval (int object_size_type) static inline tree size_unknown (int object_size_type) { - return size_int (unknown (object_size_type)); + return ((object_size_type & OST_MINIMUM) + ? size_zero_node : TYPE_MAX_VALUE (sizetype)); } /* Grow object_sizes[OBJECT_SIZE_TYPE] to num_ssa_names. */