diff mbox series

[1/2] rebuild dominance tree during CFG cleanup

Message ID 20201117011058.53995-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series simplify CBR-CBR on the same condition | expand

Commit Message

Luc Van Oostenryck Nov. 17, 2020, 1:10 a.m. UTC
Currently, the dominance tree is build once, just before the
SSA conversion.

However, changes in the CFG potentially changes the dominance
relationships.

So, rebuild the dominance tree after changes to the CFG.

Note: This doesn't seems to significantly affect the performance
      (at least when used on the kernel):
	before			after
	real	 4m15.854s	real	 4m16.95&s
	user	71m11.390s	user	71m29.180s
	sys	28m45.222s	sys	28m46.145s

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 optimize.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/optimize.c b/optimize.c
index 338714c78e68..c047495f26cf 100644
--- a/optimize.c
+++ b/optimize.c
@@ -45,6 +45,12 @@  static void clean_up_insns(struct entrypoint *ep)
 	} END_FOR_EACH_PTR(bb);
 }
 
+static void cleanup_cfg(struct entrypoint *ep)
+{
+	kill_unreachable_bbs(ep);
+	domtree_build(ep);
+}
+
 void optimize(struct entrypoint *ep)
 {
 	if (fdump_ir & PASS_LINEARIZE)
@@ -93,7 +99,7 @@  repeat:
 		} while (repeat_phase);
 		pack_basic_blocks(ep);
 		if (repeat_phase & REPEAT_CFG_CLEANUP)
-			kill_unreachable_bbs(ep);
+			cleanup_cfg(ep);
 	} while (repeat_phase);
 
 	vrfy_flow(ep);
@@ -113,7 +119,7 @@  repeat:
 	if (simplify_flow(ep)) {
 		clear_liveness(ep);
 		if (repeat_phase & REPEAT_CFG_CLEANUP)
-			kill_unreachable_bbs(ep);
+			cleanup_cfg(ep);
 		goto repeat;
 	}