re PR tree-optimization/78224 (g++ ICE at -O2(-O1 on gcc6) and above in verify_loop_s...
authorRichard Biener <rguenther@suse.de>
Tue, 8 Nov 2016 08:03:54 +0000 (08:03 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 8 Nov 2016 08:03:54 +0000 (08:03 +0000)
2016-11-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/78224
* tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds):
Split the fallthru edge in case its successor may have PHIs.
Do not free dominance info.

* g++.dg/torture/pr78224.C: New testcase.

From-SVN: r241955

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

index ff8e061b1e61446a0d03c5fac6cc2f8b4b22c93d..64b0b93ef476d974c5fe2252d9025c3a2a78f1b4 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78224
+       * tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds):
+       Split the fallthru edge in case its successor may have PHIs.
+       Do not free dominance info.
+
 2016-11-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/78229
index ba30991faff6ec8e48101b1f92c18938ed5c7764..45a09a5e257e640ed12e10c81cfa5a077909eada 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78224
+       * g++.dg/torture/pr78224.C: New testcase.
+
 2016-11-08  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
        * gcc.dg/store_merging_1.c: Require store_merge.
diff --git a/gcc/testsuite/g++.dg/torture/pr78224.C b/gcc/testsuite/g++.dg/torture/pr78224.C
new file mode 100644 (file)
index 0000000..bb85339
--- /dev/null
@@ -0,0 +1,51 @@
+// { dg-do compile }
+
+extern "C"{
+  float sqrtf(float);
+}
+
+inline float squareroot(const float f)
+{
+  return sqrtf(f);
+}
+
+inline int squareroot(const int f)
+{
+  return static_cast<int>(sqrtf(static_cast<float>(f)));
+}
+
+template <class T>
+class vector2d
+{
+public:
+  vector2d(T nx, T ny) : X(nx), Y(ny) {}
+  T getLength() const { return squareroot( X*X + Y*Y ); }
+  T X;
+  T Y;
+};
+
+vector2d<int> getMousePos();
+
+class Client
+{
+public:
+  Client();
+  ~Client();
+};
+
+void the_game(float turn_amount)
+{
+  Client client;
+  bool first = true;
+
+  while (1) {
+      if (first) {
+        first = false;
+      } else {
+        int dx = getMousePos().X;
+        int dy = getMousePos().Y;
+
+        turn_amount = vector2d<float>(dx, dy).getLength();
+      }
+  }
+}
index 8df9b08010f885a56e860783a896bac5e60db6a5..861834d36631a6d0848a745e5279556d508ce7cc 100644 (file)
@@ -807,15 +807,20 @@ shrink_wrap_one_built_in_call_with_conds (gcall *bi_call, vec <gimple *> conds,
         can_guard_call_p.  */
       join_tgt_in_edge_from_call = find_fallthru_edge (bi_call_bb->succs);
       gcc_assert (join_tgt_in_edge_from_call);
-      free_dominance_info (CDI_DOMINATORS);
+      /* We don't want to handle PHIs.  */
+      if (EDGE_COUNT (join_tgt_in_edge_from_call->dest->preds) > 1)
+       join_tgt_bb = split_edge (join_tgt_in_edge_from_call);
+      else
+       join_tgt_bb = join_tgt_in_edge_from_call->dest;
     }
   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);
+      join_tgt_bb = join_tgt_in_edge_from_call->dest;
+    }
 
   bi_call_bsi = gsi_for_stmt (bi_call);
 
-  join_tgt_bb = join_tgt_in_edge_from_call->dest;
-
   /* Now it is time to insert the first conditional expression
      into bi_call_bb and split this bb so that bi_call is
      shrink-wrapped.  */