aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-12-01 00:10:35 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-03-24 22:15:22 +0100
commit74d910d66998c7c63f0b05bcac7287b46043c720 (patch)
treea62face3dc6fda9d48736b16f83ac6d58acb3016
parent92169b2aecd4794b7eee21f869228967245c87e2 (diff)
downloadsparse-74d910d66998c7c63f0b05bcac7287b46043c720.tar.gz
extract try_to_kill_store() from kill_dominated_stores()
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>
-rw-r--r--memops.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/memops.c b/memops.c
index ff54208e..31fd2d3e 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 */