linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 5/5] kill redundant stores (local)
Date: Sun, 11 Apr 2021 00:30:44 +0200	[thread overview]
Message-ID: <20210410223044.86100-6-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20210410223044.86100-1-luc.vanoostenryck@gmail.com>

A store is called 'redundant' when the corresponding location
already contains the value that will be stored.

This patch removes such stores in the case where the memops
which make them redundant is in the same basic block.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 memops.c                                  | 5 +++++
 validation/memops/kill-redundant-store0.c | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/memops.c b/memops.c
index 44d90754d279..f734f6eb7398 100644
--- a/memops.c
+++ b/memops.c
@@ -213,6 +213,11 @@ static bool try_to_kill_store(pseudo_t pseudo, struct instruction *insn,
 		/* possible partial dominance? */
 		if (dominance < 0)
 			return false;
+		if (insn->target == dom->target && insn->bb == dom->bb) {
+			// found a memop which makes the store redundant
+			kill_instruction_force(insn);
+			return false;
+		}
 		if (dom->opcode == OP_LOAD)
 			return false;
 		if (dom->is_volatile)
diff --git a/validation/memops/kill-redundant-store0.c b/validation/memops/kill-redundant-store0.c
index e911166dd953..8819938fe763 100644
--- a/validation/memops/kill-redundant-store0.c
+++ b/validation/memops/kill-redundant-store0.c
@@ -7,7 +7,6 @@ void foo(int *ptr)
 /*
  * check-name: kill-redundant-store0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-excludes: store
-- 
2.31.1


      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 ` [PATCH 4/5] kill parent's dead stores too Luc Van Oostenryck
2021-04-10 22:30 ` Luc Van Oostenryck [this message]

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-6-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).