From patchwork Fri Dec 17 21:23:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 49070 Return-Path: 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 4DF263858431 for ; Fri, 17 Dec 2021 21:24:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from insect.birch.relay.mailchannels.net (insect.birch.relay.mailchannels.net [23.83.209.93]) by sourceware.org (Postfix) with ESMTPS id 1DD0A3858407 for ; Fri, 17 Dec 2021 21:24:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1DD0A3858407 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 5523D821E39; Fri, 17 Dec 2021 21:24:05 +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 A30EE821F7A; Fri, 17 Dec 2021 21:24:04 +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.105.57.85 (trex/6.4.3); Fri, 17 Dec 2021 21:24:05 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Occur-Rock: 4cb88abc78cec499_1639776245018_3101524677 X-MC-Loop-Signature: 1639776245018:3145750170 X-MC-Ingress-Time: 1639776245018 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 4JG26V4xLtz30; Fri, 17 Dec 2021 13:24:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1639776244; bh=g8iqfgmyai4zzIu6Xy/MMe4n3kU=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=hv65q7jQHD7rjzpyXZSNoGQcuP+lBtKUxx6Wt9s4tIB2bxEndiXHGWiAbyjc7zBGF grrhHl8BlmpS8a8fqlsSOIKOzw81m3DWLdWwNwAFPjycpfvR6L4sbu52tCqlC1gk1M Bj7yu3Qtd1nb/yZ5DlmuXCmHbyzkNbV/5dLFWS30= From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/103759: Truncate unknown to sizetype on compare Date: Sat, 18 Dec 2021 02:53:47 +0530 Message-Id: <20211217212347.72617-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3037.8 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+patchwork=sourceware.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 after conversion to HOST_WIDE_INT would be incorrect. Instead, truncate unknown (object_size_type) to sizetype to compare with the computed size to evaluate if it is unknown. gcc/ChangeLog: PR tree-optimization/103759 * tree-object-size (size_unknown_p): Construct a size_unknown and compare with VAL. Signed-off-by: Siddhesh Poyarekar --- This fixes all the 32-bit torture failures on i686, tested with configuration: --enable-clocale=gnu --with-system-zlib --enable-shared --enable-cet --with-demangler-in-ld --enable-libmpx i686-linux --with-fpmath=sse --enable-languages=c,c++,lto --disable-bootstrap and also with x86_64 to ensure I didn't regress there. I have a full bootstrap build and test run in progress. gcc/tree-object-size.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 71f6b747d05..71c7935cb07 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -100,15 +100,6 @@ 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 a tree with initial value for OBJECT_SIZE_TYPE. */ static inline tree @@ -125,6 +116,15 @@ size_unknown (int object_size_type) return size_int (unknown (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_CODE (val) == INTEGER_CST + && tree_int_cst_compare (val, size_unknown (object_size_type))); +} + /* Grow object_sizes[OBJECT_SIZE_TYPE] to num_ssa_names. */ static inline void