]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR tree-optimization/58165
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Aug 2013 08:57:29 +0000 (08:57 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Aug 2013 08:57:29 +0000 (08:57 +0000)
* tree-call-cdce.c (shrink_wrap_one_built_in_call): If
bi_call must be the last stmt in a bb, don't split_block, instead
use fallthru edge from it and give up if there is none.
Release conds vector when returning early.

* g++.dg/opt/pr58165.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201780 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr58165.C [new file with mode: 0644]
gcc/tree-call-cdce.c

index a5975f55d6ccefb2bb90658309f8ff53997808b4..810b8a5528814696056176f4ab07c14a4768a44a 100644 (file)
@@ -1,3 +1,11 @@
+2013-08-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/58165
+       * tree-call-cdce.c (shrink_wrap_one_built_in_call): If
+       bi_call must be the last stmt in a bb, don't split_block, instead
+       use fallthru edge from it and give up if there is none.
+       Release conds vector when returning early.
+
 2013-08-14  Xinliang David Li  <davidxl@google.com>
 
        * config/i386/i386.c (ix86_option_override_internal):
index 9b115a48df313b2ea4303d52d2d56728f660ba2b..84679bbbb6551345194d923ab742ca67b921a4f1 100644 (file)
@@ -1,3 +1,8 @@
+2013-08-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/58165
+       * g++.dg/opt/pr58165.C: New test.
+
 2013-08-14  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51912
diff --git a/gcc/testsuite/g++.dg/opt/pr58165.C b/gcc/testsuite/g++.dg/opt/pr58165.C
new file mode 100644 (file)
index 0000000..d758e37
--- /dev/null
@@ -0,0 +1,14 @@
+// PR tree-optimization/58165
+// { dg-do compile }
+// { dg-options "-O2" }
+
+extern "C" float sqrtf (float);
+
+struct A { A (); ~A (); };
+
+void
+foo (double d)
+{
+  A a;
+  sqrtf (d);
+}
index 8edcad93b8b34a210e768ae4159bf144917adfe5..1396388676b3f23494aa58d9b46e2e959e9ab200 100644 (file)
@@ -726,15 +726,28 @@ shrink_wrap_one_built_in_call (gimple bi_call)
      return false and do not do any transformation for
      the call.  */
   if (nconds == 0)
-    return false;
+    {
+      conds.release ();
+      return false;
+    }
 
   bi_call_bb = gimple_bb (bi_call);
 
-  /* Now find the join target bb -- split
-     bi_call_bb if needed.  */
-  bi_call_bsi = gsi_for_stmt (bi_call);
+  /* Now find the join target bb -- split bi_call_bb if needed.  */
+  if (stmt_ends_bb_p (bi_call))
+    {
+      /* If the call must be the last in the bb, don't split the block,
+        it could e.g. have EH edges.  */
+      join_tgt_in_edge_from_call = find_fallthru_edge (bi_call_bb->succs);
+      if (join_tgt_in_edge_from_call == NULL)
+       {
+         conds.release ();
+         return false;
+       }
+    }
+  else
+    join_tgt_in_edge_from_call = split_block (bi_call_bb, bi_call);
 
-  join_tgt_in_edge_from_call = split_block (bi_call_bb, bi_call);
   bi_call_bsi = gsi_for_stmt (bi_call);
 
   join_tgt_bb = join_tgt_in_edge_from_call->dest;