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 2/5] extract try_to_kill_store() from kill_dominated_stores()
Date: Sun, 11 Apr 2021 00:30:41 +0200	[thread overview]
Message-ID: <20210410223044.86100-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20210410223044.86100-1-luc.vanoostenryck@gmail.com>

Move the test/replace part of the store simplification in a
separate function so that it can be reused.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 memops.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/memops.c b/memops.c
index ff54208e2d54..31fd2d3eaffc 100644
--- a/memops.c
+++ b/memops.c
@@ -204,6 +204,23 @@ next_load:
 	} END_FOR_EACH_PTR_REVERSE(insn);
 }
 
+static bool try_to_kill_store(pseudo_t pseudo, struct instruction *insn,
+			     struct instruction *dom, int local)
+{
+	int dominance = dominates(pseudo, insn, dom, local);
+
+	if (dominance) {
+		/* possible partial dominance? */
+		if (dominance < 0)
+			return false;
+		if (dom->opcode == OP_LOAD)
+			return false;
+		/* Yeehaa! Found one! */
+		kill_instruction_force(dom);
+	}
+	return true;
+}
+
 static void kill_dominated_stores(struct basic_block *bb)
 {
 	struct instruction *insn;
@@ -223,19 +240,10 @@ static void kill_dominated_stores(struct basic_block *bb)
 
 			local = local_pseudo(pseudo);
 			RECURSE_PTR_REVERSE(insn, dom) {
-				int dominance;
 				if (!dom->bb)
 					continue;
-				dominance = dominates(pseudo, insn, dom, local);
-				if (dominance) {
-					/* possible partial dominance? */
-					if (dominance < 0)
-						goto next_store;
-					if (dom->opcode == OP_LOAD)
-						goto next_store;
-					/* Yeehaa! Found one! */
-					kill_instruction_force(dom);
-				}
+				if (!try_to_kill_store(pseudo, insn, dom, local))
+					goto next_store;
 			} END_FOR_EACH_PTR_REVERSE(dom);
 
 			/* OK, we should check the parents now */
-- 
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 ` Luc Van Oostenryck [this message]
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 ` [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-3-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).