aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-01-10 14:50:32 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-01-10 14:50:32 +0000
commitaae23693f8a8274100dafe63c3d2e6498b24461f (patch)
tree9bc726b30e0677da201192f129dcd363130717d8
parenta0843aedb8ad71a7b14847fb4d52a64f8ce5a501 (diff)
downloadgcc-aae23693f8a8274100dafe63c3d2e6498b24461f.zip
gcc-aae23693f8a8274100dafe63c3d2e6498b24461f.tar.gz
gcc-aae23693f8a8274100dafe63c3d2e6498b24461f.tar.bz2
re PR tree-optimization/79034 (error: missing PHI def in verify_gimple_in_cfg)
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. From-SVN: r244274
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr79034.C52
-rw-r--r--gcc/tree-call-cdce.c13
4 files changed, 75 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ab86ebd..23b5fc7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2017-01-10 Martin Liska <mliska@suse.cz>
* ipa-icf.c (sort_sem_items_by_decl_uid): New function.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ecbc8fa..bc86b4f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-10 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/79034
+ * g++.dg/torture/pr79034.C: New testcase.
+
2017-01-10 Martin Liska <mliska@suse.cz>
* gcc.dg/ipa/ipa-icf-1.c: Change scanned pattern.
diff --git a/gcc/testsuite/g++.dg/torture/pr79034.C b/gcc/testsuite/g++.dg/torture/pr79034.C
new file mode 100644
index 0000000..802c0aa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr79034.C
@@ -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;
+ }
+ }
+ }
+}
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index e668304..10d2c47 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -811,7 +811,18 @@ shrink_wrap_one_built_in_call_with_conds (gcall *bi_call, vec <gimple *> conds,
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;
+ {
+ 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
{