This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Do not emit SAVE_EXPR for already assigned SSA_NAMEs (PR71606).


Hi.

This is candidate patch for the PR, which do not create SAVE_EXPR trees for
already assigned SSA_NAMEs.

Patch survives reg&bootstrap on x86_64-linux-gnu.

Thoughts?
Thanks,
Martin
>From 91d01830302171b5cd53fa2f32cc881b2b50762f Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 22 Jun 2016 18:07:55 +0200
Subject: [PATCH] Do not emit SAVE_EXPR for already assigned SSA_NAMEs
 (PR71606).

gcc/ChangeLog:

2016-06-22  Martin Liska  <mliska@suse.cz>

	PR middle-end/71606
	* tree.c (save_expr): Do not generate SAVE_EXPR if the
	argument is already an assigned SSA_NAME.

gcc/testsuite/ChangeLog:

2016-06-22  Martin Liska  <mliska@suse.cz>

	* gcc.dg/torture/pr71606.c: New test.
---
 gcc/testsuite/gcc.dg/torture/pr71606.c | 11 +++++++++++
 gcc/tree.c                             |  3 +++
 2 files changed, 14 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr71606.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr71606.c b/gcc/testsuite/gcc.dg/torture/pr71606.c
new file mode 100644
index 0000000..b0cc26a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr71606.c
@@ -0,0 +1,11 @@
+_Complex a;
+void fn1 ();
+
+int main () {
+  fn1 (a);
+  return 0;
+}
+
+void fn1 (__complex__ long double p1) {
+  __imag__ p1 = 6.0L;
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index bc60190..344eb61 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3340,6 +3340,9 @@ save_expr (tree expr)
   tree t = fold (expr);
   tree inner;
 
+  if (TREE_CODE (expr) == SSA_NAME && SSA_NAME_DEF_STMT (expr))
+    return t;
+
   /* If the tree evaluates to a constant, then we don't want to hide that
      fact (i.e. this allows further folding, and direct checks for constants).
      However, a read-only object that has side effects cannot be bypassed.
-- 
2.8.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]