@@ -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)
new file mode 100644
@@ -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
+ */
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@gmail.com> --- memops.c | 5 +++++ validation/memops/kill-dead-loads00.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 validation/memops/kill-dead-loads00.c