]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl-optimization/54052 - RTL SSA PHI insertion compile-time hog
authorRichard Biener <rguenther@suse.de>
Mon, 19 Feb 2024 10:10:50 +0000 (11:10 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 19 Feb 2024 13:42:15 +0000 (14:42 +0100)
The following tries to address the PHI insertion compile-time hog in
RTL fwprop observed with the PR54052 testcase where the loop computing
the "unfiltered" set of variables possibly needing PHI nodes for each
block exhibits quadratic compile-time and memory-use.

It does so by pruning the local DEFs with LR_OUT of the block, removing
regs that can never be LR_IN (defined by this block) in the dominance
frontier.

PR rtl-optimization/54052
* rtl-ssa/blocks.cc (function_info::place_phis): Filter
local defs by LR_OUT.

gcc/rtl-ssa/blocks.cc

index 8996443e8d5aaf322b133abc16b60babf8a6bdfc..cf4224e61ecf7dc91e3741993aa9732603a8d6d9 100644 (file)
@@ -645,7 +645,12 @@ function_info::place_phis (build_info &bi)
       if (bitmap_empty_p (&frontiers[b1]))
        continue;
 
-      bitmap b1_def = &DF_LR_BB_INFO (BASIC_BLOCK_FOR_FN (m_fn, b1))->def;
+      // Defs in B1 that are possibly in LR_IN in the dominance frontier
+      // blocks.
+      auto_bitmap b1_def;
+      bitmap_and (b1_def, &DF_LR_BB_INFO (BASIC_BLOCK_FOR_FN (m_fn, b1))->def,
+                 DF_LR_OUT (BASIC_BLOCK_FOR_FN (m_fn, b1)));
+
       bitmap_iterator bmi;
       unsigned int b2;
       EXECUTE_IF_SET_IN_BITMAP (&frontiers[b1], 0, b2, bmi)