]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/111975 - dump -> GIMPLE FE roundtrip improvements
authorRichard Biener <rguenther@suse.de>
Mon, 18 Dec 2023 12:40:46 +0000 (13:40 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 18 Dec 2023 14:25:50 +0000 (15:25 +0100)
The following improves the manual work needed to make a -gimple dump
valid input to the GIMPLE FE.  First of all it recognizes the 'sizetype'
tree and dumps it as __SIZETYPE__, then it changes dumping vector types
without name from 'vector(n) T' to 'T [[gnu::vector_size(n')]]' which
we can parse in most relevant contexts (and that's shorter than
using __attribute__).  Third it avoids a NULL_TREE TMR_STEP when
it would be one, an optimization that's re-done when generating RTL.

PR middle-end/111975
* tree-pretty-print.cc (dump_generic_node): Dump
sizetype as __SIZETYPE__ with TDF_GIMPLE.
Dump unnamed vector types as T [[gnu::vector_size(n)]] with
TDF_GIMPLE.
* tree-ssa-address.cc (create_mem_ref_raw): Never generate
a NULL STEP when INDEX is specified.

gcc/tree-pretty-print.cc
gcc/tree-ssa-address.cc

index 86a7d162eaefce5429e00ab69f1aeea9601d7f96..46e14398581dc37193ce7046a583265d3b310a2d 100644 (file)
@@ -2002,7 +2002,9 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
          }
        else if (tclass == tcc_type)
          {
-           if (TYPE_NAME (node))
+           if ((flags & TDF_GIMPLE) && node == sizetype)
+             pp_string (pp, "__SIZETYPE__");
+           else if (TYPE_NAME (node))
              {
                if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
                  pp_tree_identifier (pp, TYPE_NAME (node));
@@ -2014,11 +2016,22 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
              }
            else if (TREE_CODE (node) == VECTOR_TYPE)
              {
-               pp_string (pp, "vector");
-               pp_left_paren (pp);
-               pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
-               pp_string (pp, ") ");
-               dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
+               if (flags & TDF_GIMPLE)
+                 {
+                   dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
+                   pp_string (pp, " [[gnu::vector_size(");
+                   pp_wide_integer
+                     (pp, tree_to_poly_uint64 (TYPE_SIZE_UNIT (node)));
+                   pp_string (pp, ")]]");
+                 }
+               else
+                 {
+                   pp_string (pp, "vector");
+                   pp_left_paren (pp);
+                   pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
+                   pp_string (pp, ") ");
+                   dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
+                 }
              }
            else if (TREE_CODE (node) == INTEGER_TYPE)
              {
index b942799f6f54613260ef4face08ebff02274505a..dde5f9f8970357827894b7abaf3cae095c8eedd5 100644 (file)
@@ -369,9 +369,6 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr,
       && !valid_mem_ref_p (TYPE_MODE (type), TYPE_ADDR_SPACE (type), addr))
     return NULL_TREE;
 
-  if (addr->step && integer_onep (addr->step))
-    addr->step = NULL_TREE;
-
   if (addr->offset)
     addr->offset = fold_convert (alias_ptr_type, addr->offset);
   else