diff mbox

[7/7] kds: fix recursion in kill_dead_stores_bb()

Message ID 20180319003354.90872-8-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Luc Van Oostenryck March 19, 2018, 12:33 a.m. UTC
In kill_dead_stores_bb(), after having scanned the current BB,
we may recurse into the parent BBs. But we must do this only if
we're sure that the store there may not be needed in another BB.
In other words, we must do this only if the current BB is the only
child of the parent.

However, if one of the parent has more than one child, instead
of trying the next parent, the function stops there and returns.
Furthermore, the check is done with an open loop instead of using
the helper bb_list_size().

Fix this by using bb_list_size() to check if the parent has only
one child, do the recursion if it is the case and try the next
parent if not.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 flow.c                          | 7 ++-----
 validation/optim/kill-stores2.c | 1 -
 2 files changed, 2 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/flow.c b/flow.c
index 2c685cee6..1dade8dd8 100644
--- a/flow.c
+++ b/flow.c
@@ -598,11 +598,8 @@  static void kill_dead_stores_bb(pseudo_t pseudo, unsigned long generation, struc
 	} END_FOR_EACH_PTR_REVERSE(insn);
 
 	FOR_EACH_PTR(bb->parents, parent) {
-		struct basic_block *child;
-		FOR_EACH_PTR(parent->children, child) {
-			if (child && child != bb)
-				return;
-		} END_FOR_EACH_PTR(child);
+		if (bb_list_size(parent->children) > 1)
+			continue;
 		kill_dead_stores_bb(pseudo, generation, parent, local);
 	} END_FOR_EACH_PTR(parent);
 }
diff --git a/validation/optim/kill-stores2.c b/validation/optim/kill-stores2.c
index 692888489..861b5ece0 100644
--- a/validation/optim/kill-stores2.c
+++ b/validation/optim/kill-stores2.c
@@ -11,7 +11,6 @@  static void foo(void)
 /*
  * check-name: kill-stores2
  * check-command: test-linearize $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-excludes: store\\.