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]

fix tree-opt/22022


The comment pretty much says it all.  Tested (with some difficulty
due to prevailing conditions) on i686-linux.


r~


        * tree-complex.c (update_phi_components): Avoid no-op moves.

Index: tree-complex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-complex.c,v
retrieving revision 2.29
diff -u -p -d -r2.29 tree-complex.c
--- tree-complex.c	16 Jun 2005 18:09:34 -0000	2.29
+++ tree-complex.c	17 Jun 2005 00:53:06 -0000
@@ -577,6 +577,12 @@ update_phi_components (basic_block bb)
 	    tree arg = PHI_ARG_DEF (phi, i);
 	    tree r, i;
 
+	    /* Avoid no-op assignments.  This also prevents insertting stmts
+	       onto abnormal edges, assuming the PHI isn't already broken.  */
+	    if (TREE_CODE (arg) == SSA_NAME
+		&& SSA_NAME_VAR (arg) == SSA_NAME_VAR (lhs))
+	      continue;
+
 	    r = extract_component (NULL, arg, 0, false);
 	    i = extract_component (NULL, arg, 1, false);
 	    update_complex_components_on_edge (e, NULL, lhs, r, i);
Index: testsuite/g++.dg/opt/complex2.C
===================================================================
RCS file: testsuite/g++.dg/opt/complex2.C
diff -N testsuite/g++.dg/opt/complex2.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/opt/complex2.C	17 Jun 2005 00:53:06 -0000
@@ -0,0 +1,24 @@
+// PR 22022
+// { dg-do compile }
+// { dg-options "-O2" }
+
+_Complex float f();
+_Complex float g();
+_Complex float h()throw();
+void i(_Complex float)throw();
+
+void j(void)
+{
+  _Complex float x = h();
+  try
+  {
+    try
+    {
+      x = f();
+    }catch (...)
+    {
+      x = g();
+    }
+  }catch(...){}
+  i(x);
+}
Index: testsuite/g++.dg/opt/complex3.C
===================================================================
RCS file: testsuite/g++.dg/opt/complex3.C
diff -N testsuite/g++.dg/opt/complex3.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/opt/complex3.C	17 Jun 2005 00:53:06 -0000
@@ -0,0 +1,24 @@
+// PR 22022
+// { dg-do compile }
+// { dg-options "-O2" }
+
+_Complex float f();
+_Complex float g();
+_Complex float h()throw();
+void i(float)throw();
+
+float j(void)
+{
+  _Complex float x = h();
+  try
+  {
+    try
+    {
+      x = f();
+    }catch (...)
+    {
+      x += g();
+    }
+  }catch(...){}
+  i(__builtin_crealf(x)+__builtin_cimagf(x));
+}


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