rtl-optimization/98144 - tame REE memory usage
authorRichard Biener <rguenther@suse.de>
Fri, 29 Jan 2021 09:23:40 +0000 (10:23 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 29 Jan 2021 11:01:58 +0000 (12:01 +0100)
This changes the REE dataflow to change the explicit all-ones
starting solution to be implicit via a visited flag, removing
the need to initially start with fully populated bitmaps for
all basic-blocks.  That reduces peak memory use when compiling
the RTL checking enabled insn-extract.c testcase from PR98144
from 6GB to less than 2GB.

2021-01-29  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/98144
* df.h (df_mir_bb_info): Add con_visited member.
* df-problems.c (df_mir_alloc): Initialize con_visited,
do not fully populate IN and OUT.
(df_mir_reset): Likewise.
(df_mir_confluence_0): Set con_visited.
(df_mir_confluence_n): Properly handle implicitely
fully populated IN and OUT as designated by con_visited
and update con_visited accordingly.

gcc/df-problems.c
gcc/df.h

index 53a1f0d9dd61eca12c0b71bbf2d1538aba391744..8fe58581f3272e94ff83bd8f1a2e4c58384c11dc 100644 (file)
@@ -1917,8 +1917,7 @@ df_mir_alloc (bitmap all_blocks)
          bitmap_initialize (&bb_info->gen, &problem_data->mir_bitmaps);
          bitmap_initialize (&bb_info->in, &problem_data->mir_bitmaps);
          bitmap_initialize (&bb_info->out, &problem_data->mir_bitmaps);
-         bitmap_set_range (&bb_info->in, 0, DF_REG_SIZE (df));
-         bitmap_set_range (&bb_info->out, 0, DF_REG_SIZE (df));
+         bb_info->con_visited = false;
        }
     }
 
@@ -1941,9 +1940,8 @@ df_mir_reset (bitmap all_blocks)
       gcc_assert (bb_info);
 
       bitmap_clear (&bb_info->in);
-      bitmap_set_range (&bb_info->in, 0, DF_REG_SIZE (df));
       bitmap_clear (&bb_info->out);
-      bitmap_set_range (&bb_info->out, 0, DF_REG_SIZE (df));
+      bb_info->con_visited = false;
     }
 }
 
@@ -2021,6 +2019,7 @@ df_mir_confluence_0 (basic_block bb)
   class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb->index);
 
   bitmap_clear (&bb_info->in);
+  bb_info->con_visited = true;
 }
 
 
@@ -2029,12 +2028,27 @@ df_mir_confluence_0 (basic_block bb)
 static bool
 df_mir_confluence_n (edge e)
 {
-  bitmap op1 = &df_mir_get_bb_info (e->dest->index)->in;
-  bitmap op2 = &df_mir_get_bb_info (e->src->index)->out;
-
   if (e->flags & EDGE_FAKE)
     return false;
 
+  df_mir_bb_info *src_info = df_mir_get_bb_info (e->src->index);
+  /* If SRC was not visited yet then we'll and with all-ones which
+     means no changes.  Do not consider DST con_visited by this
+     operation alone either.  */
+  if (!src_info->con_visited)
+    return false;
+
+  df_mir_bb_info *dst_info = df_mir_get_bb_info (e->dest->index);
+  bitmap op1 = &dst_info->in;
+  bitmap op2 = &src_info->out;
+  /* If DEST was not visited yet just copy the SRC bitmap.  */
+  if (!dst_info->con_visited)
+    {
+      dst_info->con_visited = true;
+      bitmap_copy (op1, op2);
+      return true;
+    }
+
   /* A register is must-initialized at the entry of a basic block iff it is
      must-initialized at the exit of all the predecessors.  */
   return bitmap_and_into (op1, op2);
index 88d35e49afd134a712f117b395fe460b8c888000..5effefaa6e3d961cb05c4ac5157fdacd29ec16f4 100644 (file)
--- a/gcc/df.h
+++ b/gcc/df.h
@@ -929,6 +929,7 @@ public:
   /* The results of the dataflow problem.  */
   bitmap_head in;    /* At the top of the block.  */
   bitmap_head out;   /* At the bottom of the block.  */
+  bool con_visited;  /* Visited by con_fun_{0,n}.  */
 };