[PATCH] memops: kill dead loads before phi-node conversion

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

 



During load simplification it may happen that a load is unused
but if this fact is ignored and the usual conversion to a phi-node
is node, then this value may seem to be needed and can't be anymore
be simplified away.

Fix this by removing dead loads during load simplification.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 memops.c                              |  5 +++++
 validation/memops/kill-dead-loads00.c | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 validation/memops/kill-dead-loads00.c

diff --git a/memops.c b/memops.c
index badcdbbb9378..6baf4d163b00 100644
--- a/memops.c
+++ b/memops.c
@@ -111,6 +111,11 @@ static void simplify_loads(struct basic_block *bb)
 			if (insn->is_volatile)
 				continue;
 
+			if (!has_users(insn->target)) {
+				kill_instruction(insn);
+				continue;
+			}
+
 			RECURSE_PTR_REVERSE(insn, dom) {
 				int dominance;
 				if (!dom->bb)
diff --git a/validation/memops/kill-dead-loads00.c b/validation/memops/kill-dead-loads00.c
new file mode 100644
index 000000000000..df7ec037e2f2
--- /dev/null
+++ b/validation/memops/kill-dead-loads00.c
@@ -0,0 +1,22 @@
+void fun(void);
+
+void foo(int *p)
+{
+	for (*p; *p; *p) {
+l:
+		fun();
+	}
+
+	if (0)
+		goto l;
+}
+
+/*
+ * check-name: kill-dead-loads00
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: phi\\.
+ * check-output-pattern(1): load\\.
+ * check-output-end
+ */
-- 
2.29.2




[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