From e0c12f39daec8b2d13fb84e80033f7d9052374c7 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Tue, 1 Dec 2020 00:10:35 +0100 Subject: kill parent's dead stores too kill_dominated_stores() identify and remove dead stores (stores unneeded because the same location is overwritten later by another store) only when both stores are in the same basic block. Slightly improve this by also handling the case when the dead store is in a parent BB of the "live" store. Signed-off-by: Luc Van Oostenryck --- memops.c | 16 ++++++++++++++++ validation/memops/kill-dead-store-parent0.c | 1 - validation/memops/kill-dead-store-parent2.c | 1 - 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/memops.c b/memops.c index 8020f2e6..44d90754 100644 --- a/memops.c +++ b/memops.c @@ -231,6 +231,7 @@ static void kill_dominated_stores(struct basic_block *bb) if (!insn->bb) continue; if (insn->opcode == OP_STORE) { + struct basic_block *par; struct instruction *dom; pseudo_t pseudo = insn->src; int local; @@ -249,6 +250,21 @@ static void kill_dominated_stores(struct basic_block *bb) } END_FOR_EACH_PTR_REVERSE(dom); /* OK, we should check the parents now */ + FOR_EACH_PTR(bb->parents, par) { + + if (bb_list_size(par->children) != 1) + goto next_parent; + FOR_EACH_PTR(par->insns, dom) { + if (!dom->bb) + continue; + if (dom == insn) + goto next_parent; + if (!try_to_kill_store(pseudo, insn, dom, local)) + goto next_parent; + } END_FOR_EACH_PTR(dom); +next_parent: + ; + } END_FOR_EACH_PTR(par); } next_store: /* Do the next one */; diff --git a/validation/memops/kill-dead-store-parent0.c b/validation/memops/kill-dead-store-parent0.c index 1413134b..c1b2466c 100644 --- a/validation/memops/kill-dead-store-parent0.c +++ b/validation/memops/kill-dead-store-parent0.c @@ -8,7 +8,6 @@ void foo(int *ptr, int p) /* * check-name: kill-dead-store-parent0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(1): store diff --git a/validation/memops/kill-dead-store-parent2.c b/validation/memops/kill-dead-store-parent2.c index b563fd31..4f7b9dd9 100644 --- a/validation/memops/kill-dead-store-parent2.c +++ b/validation/memops/kill-dead-store-parent2.c @@ -19,7 +19,6 @@ l20: /* * check-name: kill-dead-store-parent2 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(1): store -- cgit 1.2.3-korg