]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Thu, 26 Jan 2017 13:08:43 +0000 (13:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 26 Jan 2017 13:08:43 +0000 (13:08 +0000)
2017-01-26  Richard Biener  <rguenther@suse.de>

Backport from mainline
2016-01-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79034
* tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds):
Propagate out degenerate PHIs in the joiner.

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

2016-11-07  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: r244930

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

index 84f84e528bcc10edfa8a405c741f1268179be5a5..8126dfb5cf48d13117522e9722d08f4e5eac0b83 100644 (file)
@@ -1,3 +1,19 @@
+2017-01-26  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-01-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79034
+       * tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds):
+       Propagate out degenerate PHIs in the joiner.
+
+       2016-11-07  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.
+
 2017-01-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index a9c135a08778f1cf27211ec9ccc939d13fa77487..99dd282d6c6345188efa9b809f8da731be7c0203 100644 (file)
@@ -1,3 +1,16 @@
+2017-01-26  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-01-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79034
+       * g++.dg/torture/pr79034.C: New testcase.
+
+       2016-11-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78224
+       * g++.dg/torture/pr78224.C: New testcase.
+
 2017-01-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
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();
+      }
+  }
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr79034.C b/gcc/testsuite/g++.dg/torture/pr79034.C
new file mode 100644 (file)
index 0000000..802c0aa
--- /dev/null
@@ -0,0 +1,52 @@
+/* { dg-do compile } */
+
+extern "C" {
+    float sqrtf(float);
+}
+
+class T {
+public:
+    float floats[1];
+
+    inline float length() const {
+       return sqrtf(floats[0]);
+    }
+};
+
+void destruct(void *);
+
+class Container {
+
+    T Ts[1];
+
+public:
+    ~Container() {
+       destruct((void *)Ts);
+    }
+
+    T& operator[](int n) {
+       return Ts[0];
+    }
+};
+
+void fill(Container&);
+
+void doit()
+{
+  Container data;
+  float max = 10;
+
+  int i, j, k;
+
+  for (i = 0; i < 10; i++) {
+      for (j = 1; j < 10; j++) {
+         if (max < 5)
+           break;
+         fill( data);
+         max = data[0].length();
+         for (k = 1; k < j; k++) {
+             max = 5;
+         }
+      }
+  }
+}
index f0b3ce77c87ec44f5214636fc526037198375e32..cef9a2a0750ffe94250eb7744c725020dcd10297 100644 (file)
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-into-ssa.h"
 #include "tree-pass.h"
 #include "flags.h"
+#include "tree-phinodes.h"
 \f
 
 /* Conditional dead call elimination
@@ -766,14 +767,31 @@ shrink_wrap_one_built_in_call (gcall *bi_call)
       join_tgt_in_edge_from_call = find_fallthru_edge (bi_call_bb->succs);
       if (join_tgt_in_edge_from_call == NULL)
         return false;
+      /* 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;
+         /* We may have degenerate PHIs in the destination.  Propagate
+            those out.  */
+         for (gphi_iterator i = gsi_start_phis (join_tgt_bb); !gsi_end_p (i);)
+           {
+             gphi *phi = i.phi ();
+             replace_uses_by (gimple_phi_result (phi),
+                              gimple_phi_arg_def (phi, 0));
+             remove_phi_node (&i, true);
+           }
+       }
     }
   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.  */