https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85627

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed by, for example, the following which keeps EH intact for the original
testcase if combined with the tree.c fix

Index: gcc/tree-complex.c
===================================================================
--- gcc/tree-complex.c  (revision 259879)
+++ gcc/tree-complex.c  (working copy)
@@ -1015,14 +1015,25 @@ expand_complex_libcall (gimple_stmt_iter
   if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt))
     gimple_purge_dead_eh_edges (gsi_bb (*gsi));

-  if (gimple_in_ssa_p (cfun))
+  type = TREE_TYPE (type);
+  if (stmt_can_throw_internal (stmt))
     {
-      type = TREE_TYPE (type);
-      update_complex_components (gsi, stmt,
+      edge_iterator ei;
+      edge e;
+      FOR_EACH_EDGE (e, ei, gimple_bb (stmt)->succs)
+       if (!(e->flags & EDGE_EH))
+         break;
+      basic_block bb = split_edge (e);
+      gimple_stmt_iterator gsi2 = gsi_start_bb (bb);
+      update_complex_components (&gsi2, stmt,
                                 build1 (REALPART_EXPR, type, lhs),
                                 build1 (IMAGPART_EXPR, type, lhs));
-      SSA_NAME_DEF_STMT (lhs) = stmt;
     }
+  else
+    update_complex_components (gsi, stmt,
+                              build1 (REALPART_EXPR, type, lhs),
+                              build1 (IMAGPART_EXPR, type, lhs));
+  SSA_NAME_DEF_STMT (lhs) = stmt;
 }

 /* Expand complex multiplication to scalars:

Reply via email to