summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-06 14:41:22 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-06 14:41:22 +0000
commit83c60000092ee9c5ab8dd8c3c7ecd6b3d0140c9b (patch)
tree8a0f6f699215e47e3df794c0f8c1e8b5155409b0
parenta21bc0fdfe3e09b8379b1bc896f6732e0a6a9d2b (diff)
downloadgcc-83c60000092ee9c5ab8dd8c3c7ecd6b3d0140c9b.tar.gz
2015-07-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/66772 * tree-ssa-ccp.c (ccp_visit_phi_node): Make sure that copy values are available in the PHI node BB when there are still unexecutable edges. * gcc.dg/torture/pr66772-1.c: New testcase. * gcc.dg/torture/pr66772-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225459 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr66733-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr66733-2.c46
-rw-r--r--gcc/tree-ssa-ccp.c17
5 files changed, 104 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7c43598d843..d3929fa41f6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2015-07-06 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/66772
+ * tree-ssa-ccp.c (ccp_visit_phi_node): Make sure that copy
+ values are available in the PHI node BB when there are
+ still unexecutable edges.
+
+2015-07-06 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/66767
* tree-vect-loop-manip.c (vect_create_cond_for_align_checks):
Make sure to build the alignment test on a SSA name without
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 32959d5f2cd..f7f15ddb74c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-07-06 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/66772
+ * gcc.dg/torture/pr66772-1.c: New testcase.
+ * gcc.dg/torture/pr66772-2.c: Likewise.
+
2015-07-06 Andrew Bennett <andrew.bennett@imgtec.com>
* gcc.target/mips/near-far-3.c: Allow the call to near_func to use
diff --git a/gcc/testsuite/gcc.dg/torture/pr66733-1.c b/gcc/testsuite/gcc.dg/torture/pr66733-1.c
new file mode 100644
index 00000000000..cb6e87c23c0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr66733-1.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+
+int a;
+
+int
+fn1 ()
+{
+ return 1;
+}
+
+void
+fn2 ()
+{
+ int b, j;
+ for (;;)
+ {
+ int c = 1;
+ if (j)
+ {
+ if (c)
+ break;
+ }
+ else
+ b = a;
+ fn1 () && b;
+ j = fn1 ();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr66733-2.c b/gcc/testsuite/gcc.dg/torture/pr66733-2.c
new file mode 100644
index 00000000000..6687bd0c7f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr66733-2.c
@@ -0,0 +1,46 @@
+/* { dg-do compile } */
+
+int a, b, c, e, f;
+
+void fn1 (int p) { }
+
+int
+fn2 (int p)
+{
+ return a ? p % a : 0;
+}
+
+short
+fn3 (int p)
+{
+ return (1 >> p) < 1 ? 1 : p;
+}
+
+int
+fn4 ()
+{
+ int g = 0, h = 1;
+ if (b)
+ goto lbl;
+ fn2 (0);
+ if (fn3 (1))
+ fn1 (e && c);
+ if (h)
+ {
+ int i = 1;
+lbl:
+ if (i)
+ return 0;
+ for (; g < 1; g++)
+ ;
+ }
+ for (;;)
+ f || g > 0;
+}
+
+int
+main ()
+{
+ fn4 ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 496d84006fd..05a3e57333e 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1081,6 +1081,7 @@ ccp_visit_phi_node (gphi *phi)
new_val.mask = 0;
bool first = true;
+ bool non_exec_edge = false;
for (i = 0; i < gimple_phi_num_args (phi); i++)
{
/* Compute the meet operator over all the PHI arguments flowing
@@ -1121,6 +1122,22 @@ ccp_visit_phi_node (gphi *phi)
if (new_val.lattice_val == VARYING)
break;
}
+ else
+ non_exec_edge = true;
+ }
+
+ /* In case there were non-executable edges and the value is a copy
+ make sure its definition dominates the PHI node. */
+ if (non_exec_edge
+ && new_val.lattice_val == CONSTANT
+ && TREE_CODE (new_val.value) == SSA_NAME
+ && ! SSA_NAME_IS_DEFAULT_DEF (new_val.value)
+ && ! dominated_by_p (CDI_DOMINATORS, gimple_bb (phi),
+ gimple_bb (SSA_NAME_DEF_STMT (new_val.value))))
+ {
+ new_val.lattice_val = VARYING;
+ new_val.value = NULL_TREE;
+ new_val.mask = -1;
}
if (dump_file && (dump_flags & TDF_DETAILS))