From patchwork Thu Apr 28 06:06:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 53288 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 C1DE33857822 for ; Thu, 28 Apr 2022 06:07:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1DE33857822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651126029; bh=qqFMmT7teNiFTLtTrLUI1aXisecqvQOkQwII92wSTzw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DYAnF2haf9fjxsBd6l6/lWba0szgGgwpSU2TjvQTX18sux2h3Xa8DB/rAr55RUQZA lS21BzmIT4rahXcN9mCXn8xzDZ5nDPTwVE2M5ZN0miOZxIELQUaj1p4SPJC8oWZTIa QJWCqc786N4ldPohe06pJhh2SGn2kLYftf5aUgQg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 91FD53857806 for ; Thu, 28 Apr 2022 06:06:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 91FD53857806 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 882871F37B for ; Thu, 28 Apr 2022 06:06:20 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 75DD013A8C for ; Thu, 28 Apr 2022 06:06:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5EPJG9wuamKlRwAAMHmgww (envelope-from ) for ; Thu, 28 Apr 2022 06:06:20 +0000 Date: Thu, 28 Apr 2022 08:06:20 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH][stage1] Embed real_value into REAL_CST MIME-Version: 1.0 Message-Id: <20220428060620.75DD013A8C@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The following removes the indirection to real_value from REAL_CST which doesn't seem to serve any useful purpose. Any sharing can be achieved by sharing the actual REAL_CST (which is what usually happens when copying trees) and sharing of real_value amongst different REAL_CST doesn't happen as far as I can see and would only lead to further issues like mismatching type and real_value. Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for stage1. Richard. 2022-04-27 Richard Biener * tree-core.h (tree_real_cst::real_cst_ptr): Remove pointer to real_value field. (tree_real_cst::value): Add real_value field. * tree.h (TREE_REAL_CST_PTR): Adjust. * tree.cc (build_real): Remove separate allocation. * tree-streamer-in.cc (unpack_ts_real_cst_value_fields): Likewise. cp/ * module.cc (trees_in::core_vals): Remove separate allocation for REAL_CST. --- gcc/cp/module.cc | 4 +--- gcc/tree-core.h | 2 +- gcc/tree-streamer-in.cc | 5 +---- gcc/tree.cc | 6 +----- gcc/tree.h | 2 +- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index cebf9c35c1d..18dabfcc9ac 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -6468,9 +6468,7 @@ trees_in::core_vals (tree t) case REAL_CST: if (const void *bytes = buf (sizeof (real_value))) - TREE_REAL_CST_PTR (t) - = reinterpret_cast (memcpy (ggc_alloc (), - bytes, sizeof (real_value))); + memcpy (TREE_REAL_CST_PTR (t), bytes, sizeof (real_value)); break; case STRING_CST: diff --git a/gcc/tree-core.h b/gcc/tree-core.h index f1c2b6413a3..cb4cefd369b 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1461,7 +1461,7 @@ struct GTY(()) tree_int_cst { struct GTY(()) tree_real_cst { struct tree_typed typed; - struct real_value * real_cst_ptr; + struct real_value value; }; struct GTY(()) tree_fixed_cst { diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc index a35a810f4d1..196f19c759f 100644 --- a/gcc/tree-streamer-in.cc +++ b/gcc/tree-streamer-in.cc @@ -190,7 +190,6 @@ unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr) { unsigned i; REAL_VALUE_TYPE r; - REAL_VALUE_TYPE *rp; /* Clear all bits of the real value type so that we can later do bitwise comparisons to see if two values are the same. */ @@ -204,9 +203,7 @@ unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr) for (i = 0; i < SIGSZ; i++) r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG); - rp = ggc_alloc (); - memcpy (rp, &r, sizeof (REAL_VALUE_TYPE)); - TREE_REAL_CST_PTR (expr) = rp; + memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE)); } diff --git a/gcc/tree.cc b/gcc/tree.cc index 3c39be4f501..1d2cdc82aba 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -2380,18 +2380,14 @@ tree build_real (tree type, REAL_VALUE_TYPE d) { tree v; - REAL_VALUE_TYPE *dp; int overflow = 0; /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE. Consider doing it via real_convert now. */ v = make_node (REAL_CST); - dp = ggc_alloc (); - memcpy (dp, &d, sizeof (REAL_VALUE_TYPE)); - TREE_TYPE (v) = type; - TREE_REAL_CST_PTR (v) = dp; + memcpy (TREE_REAL_CST_PTR (v), &d, sizeof (REAL_VALUE_TYPE)); TREE_OVERFLOW (v) = overflow; return v; } diff --git a/gcc/tree.h b/gcc/tree.h index 8844471e9a5..82eb8ba39d2 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1048,7 +1048,7 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, #define POLY_INT_CST_COEFF(NODE, I) \ (POLY_INT_CST_CHECK (NODE)->poly_int_cst.coeffs[I]) -#define TREE_REAL_CST_PTR(NODE) (REAL_CST_CHECK (NODE)->real_cst.real_cst_ptr) +#define TREE_REAL_CST_PTR(NODE) (&REAL_CST_CHECK (NODE)->real_cst.value) #define TREE_REAL_CST(NODE) (*TREE_REAL_CST_PTR (NODE)) #define TREE_FIXED_CST_PTR(NODE) \