[PATCH 5/5] kill redundant stores (local)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux