diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-07 13:43:01 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-14 12:39:39 +0100 |
| commit | da55cba8eadfb6f010a54de507d7d02b672f86f5 (patch) | |
| tree | 7d47076d6e26aec3e46a6f4dadc87f0e9dc95da5 | |
| parent | 517c5e6e0d637c74d60af3300ecb040d15d45158 (diff) | |
| download | sparse-dev-da55cba8eadfb6f010a54de507d7d02b672f86f5.tar.gz | |
kill dead stores when simplifying symbols
In the initial simplify_symbols() and in simplify_memops()
when a store is simplified away, it's killed via kill_store()
where its ->bb is set to NULL and the usage is removed from
the value. However the usage is not removed from the address.
As consequence, code related to the address calculation
is not optimized away as it should be since the value is
wrongly considered as needed.
Fix this by using kill_instruction_force() to remove these
stores.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | flow.c | 17 | ||||
| -rw-r--r-- | memops.c | 11 | ||||
| -rw-r--r-- | validation/optim/store-dominated.c | 1 |
3 files changed, 5 insertions, 24 deletions
@@ -544,15 +544,6 @@ found: return 1; } -static void kill_store(struct instruction *insn) -{ - if (insn) { - insn->bb = NULL; - insn->opcode = OP_SNOP; - kill_use(&insn->target); - } -} - /* Kill a pseudo that is dead on exit from the bb */ static void kill_dead_stores(pseudo_t pseudo, unsigned long generation, struct basic_block *bb, int local) { @@ -577,7 +568,7 @@ static void kill_dead_stores(pseudo_t pseudo, unsigned long generation, struct b if (insn->src == pseudo) { if (opcode == OP_LOAD) return; - kill_store(insn); + kill_instruction_force(insn); continue; } if (local) @@ -608,7 +599,7 @@ static void kill_dominated_stores(pseudo_t pseudo, struct instruction *insn, /* Unreachable store? Undo it */ if (!bb) { - kill_store(insn); + kill_instruction_force(insn); return; } if (bb->generation == generation) @@ -631,7 +622,7 @@ static void kill_dominated_stores(pseudo_t pseudo, struct instruction *insn, return; if (one->opcode == OP_LOAD) return; - kill_store(one); + kill_instruction_force(one); } END_FOR_EACH_PTR_REVERSE(one); if (!found) { @@ -723,7 +714,7 @@ external_visibility: FOR_EACH_PTR(pseudo->users, pu) { struct instruction *insn = pu->insn; if (insn->opcode == OP_STORE) - kill_store(insn); + kill_instruction_force(insn); } END_FOR_EACH_PTR(pu); } else { /* @@ -139,15 +139,6 @@ next_load: } END_FOR_EACH_PTR_REVERSE(insn); } -static void kill_store(struct instruction *insn) -{ - if (insn) { - insn->bb = NULL; - insn->opcode = OP_SNOP; - kill_use(&insn->target); - } -} - static void kill_dominated_stores(struct basic_block *bb) { struct instruction *insn; @@ -178,7 +169,7 @@ static void kill_dominated_stores(struct basic_block *bb) if (dom->opcode == OP_LOAD) goto next_store; /* Yeehaa! Found one! */ - kill_store(dom); + kill_instruction_force(dom); } } END_FOR_EACH_PTR_REVERSE(dom); diff --git a/validation/optim/store-dominated.c b/validation/optim/store-dominated.c index f1e2e6f2..d74db779 100644 --- a/validation/optim/store-dominated.c +++ b/validation/optim/store-dominated.c @@ -9,7 +9,6 @@ static void foo(void) /* * check-name: store-dominated * check-command: test-linearize $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: add\. |
