]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Embed real_value into REAL_CST
authorRichard Biener <rguenther@suse.de>
Wed, 27 Apr 2022 11:48:49 +0000 (13:48 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 5 May 2022 11:19:40 +0000 (13:19 +0200)
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.

2022-04-27  Richard Biener  <rguenther@suse.de>

* 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.

gcc/cp/
* module.cc (trees_in::core_vals): Remove separate allocation
for REAL_CST.

gcc/cp/module.cc
gcc/tree-core.h
gcc/tree-streamer-in.cc
gcc/tree.cc
gcc/tree.h

index cebf9c35c1dea3de9ae17833ebf59e6f612e8af3..18dabfcc9acc6e2c7b860c3d0f783d2c88a29790 100644 (file)
@@ -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<real_value *> (memcpy (ggc_alloc<real_value> (),
-                                                   bytes, sizeof (real_value)));
+       memcpy (TREE_REAL_CST_PTR (t), bytes, sizeof (real_value));
       break;
 
     case STRING_CST:
index 07e76e659e4393be8fdf0b4724f9bdeafdf01322..c79b8b28da3288f934817ade65996291dff73285 100644 (file)
@@ -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 {
index a35a810f4d100240341bb3d3421a77505d82c403..196f19c759f2f878b12751bcd6751aff24e16ccc 100644 (file)
@@ -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<real_value> ();
-  memcpy (rp, &r, sizeof (REAL_VALUE_TYPE));
-  TREE_REAL_CST_PTR (expr) = rp;
+  memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
 }
 
 
index 4cf3785270b38d7ca9ef77087aba729c8cdf8c84..5e8876d2b38226b4a3715c121e3d3a67b9c55c93 100644 (file)
@@ -2381,7 +2381,6 @@ tree
 build_real (tree type, REAL_VALUE_TYPE d)
 {
   tree v;
-  REAL_VALUE_TYPE *dp;
   int overflow = 0;
 
   /* dconst{1,2,m1,half} are used in various places in
@@ -2408,11 +2407,8 @@ build_real (tree type, REAL_VALUE_TYPE d)
      Consider doing it via real_convert now.  */
 
   v = make_node (REAL_CST);
-  dp = ggc_alloc<real_value> ();
-  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;
 }
index 8844471e9a5f2c8de93bb411e1c635a451d3d239..82eb8ba39d264fa7ebefb3a9de4443ea801bf4d9 100644 (file)
@@ -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) \