From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 4/5] kill parent's dead stores too
Date: Sun, 11 Apr 2021 00:30:43 +0200 [thread overview]
Message-ID: <20210410223044.86100-5-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20210410223044.86100-1-luc.vanoostenryck@gmail.com>
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 <luc.vanoostenryck@gmail.com>
---
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 8020f2e6cf03..44d90754d279 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 1413134b8c23..c1b2466ca450 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 b563fd31b669..4f7b9dd901d9 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
--
2.31.1
next prev parent reply other threads:[~2021-04-10 22:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-10 22:30 [PATCH 0/5] kill more dead stores Luc Van Oostenryck
2021-04-10 22:30 ` [PATCH 1/5] add testcases for stores simplifications Luc Van Oostenryck
2021-04-10 22:30 ` [PATCH 2/5] extract try_to_kill_store() from kill_dominated_stores() Luc Van Oostenryck
2021-04-10 22:30 ` [PATCH 3/5] volatile stores are never dead Luc Van Oostenryck
2021-04-10 22:30 ` Luc Van Oostenryck [this message]
2021-04-10 22:30 ` [PATCH 5/5] kill redundant stores (local) Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210410223044.86100-5-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).