summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-11 09:19:41 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-11 09:19:41 +0000
commit64243ab0fb231ba0528fb9bb6efd90a32bb85462 (patch)
tree000f1cb2606177d6c2c6952a5cfbd3062075c818 /gcc
parent666655e480c5d6a3866d3b5c7d7dd685205aaafc (diff)
downloadlinaro-gcc-64243ab0fb231ba0528fb9bb6efd90a32bb85462.tar.gz
linaro-gcc-64243ab0fb231ba0528fb9bb6efd90a32bb85462.tar.bz2
linaro-gcc-64243ab0fb231ba0528fb9bb6efd90a32bb85462.zip
PR tree-optimization/59417
* tree-ssa-copy.c (fini_copy_prop): If copy_of[i].value is defined in a different bb rhan var, only duplicate points-to info and not alignment info and don't duplicate range info. * tree-ssa-loop-niter.c (determine_value_range): Instead of assertion failure handle inconsistencies in range info by only using var's range info and not PHI result range infos. * gcc.c-torture/compile/pr59417.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205884 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr59417.c39
-rw-r--r--gcc/tree-ssa-copy.c20
-rw-r--r--gcc/tree-ssa-loop-niter.c10
5 files changed, 76 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 22caa76f771..10fae5ac166 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2013-12-11 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/59417
+ * tree-ssa-copy.c (fini_copy_prop): If copy_of[i].value is defined
+ in a different bb rhan var, only duplicate points-to info and
+ not alignment info and don't duplicate range info.
+ * tree-ssa-loop-niter.c (determine_value_range): Instead of
+ assertion failure handle inconsistencies in range info by only
+ using var's range info and not PHI result range infos.
+
PR tree-optimization/59386
* tree-inline.c (remap_gimple_stmt): If not id->do_not_unshare,
unshare_expr (id->retval) before passing it to gimple_build_assign.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ebd99960b42..b7e72deb7b8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2013-12-11 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/59417
+ * gcc.c-torture/compile/pr59417.c: New test.
+
PR tree-optimization/59386
* gcc.c-torture/compile/pr59386.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59417.c b/gcc/testsuite/gcc.c-torture/compile/pr59417.c
new file mode 100644
index 00000000000..227c5d84105
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr59417.c
@@ -0,0 +1,39 @@
+/* PR tree-optimization/59417 */
+
+int a, b, d;
+short c;
+
+void
+f (void)
+{
+ if (b)
+ {
+ int *e;
+
+ if (d)
+ {
+ for (; b; a++)
+ lbl1:
+ d = 0;
+
+ for (; d <= 1; d++)
+ {
+ int **q = &e;
+ for (**q = 0; **q <= 0; **q++)
+ d = 0;
+ }
+ }
+ }
+
+ else
+ {
+ int t;
+ for (c = 0; c < 77; c++)
+ for (c = 0; c < 46; c++);
+ for (; t <= 0; t++)
+ lbl2:
+ ;
+ goto lbl1;
+ }
+ goto lbl2;
+}
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 3da262b2a77..11daa5f59cb 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -567,14 +567,28 @@ fini_copy_prop (void)
if (copy_of[i].value != var
&& TREE_CODE (copy_of[i].value) == SSA_NAME)
{
+ basic_block copy_of_bb
+ = gimple_bb (SSA_NAME_DEF_STMT (copy_of[i].value));
+ basic_block var_bb = gimple_bb (SSA_NAME_DEF_STMT (var));
if (POINTER_TYPE_P (TREE_TYPE (var))
&& SSA_NAME_PTR_INFO (var)
&& !SSA_NAME_PTR_INFO (copy_of[i].value))
- duplicate_ssa_name_ptr_info (copy_of[i].value,
- SSA_NAME_PTR_INFO (var));
+ {
+ duplicate_ssa_name_ptr_info (copy_of[i].value,
+ SSA_NAME_PTR_INFO (var));
+ /* Points-to information is cfg insensitive,
+ but alignment info might be cfg sensitive, if it
+ e.g. is derived from VRP derived non-zero bits.
+ So, do not copy alignment info if the two SSA_NAMEs
+ aren't defined in the same basic block. */
+ if (var_bb != copy_of_bb)
+ mark_ptr_info_alignment_unknown
+ (SSA_NAME_PTR_INFO (copy_of[i].value));
+ }
else if (!POINTER_TYPE_P (TREE_TYPE (var))
&& SSA_NAME_RANGE_INFO (var)
- && !SSA_NAME_RANGE_INFO (copy_of[i].value))
+ && !SSA_NAME_RANGE_INFO (copy_of[i].value)
+ && var_bb == copy_of_bb)
duplicate_ssa_name_range_info (copy_of[i].value,
SSA_NAME_RANGE_TYPE (var),
SSA_NAME_RANGE_INFO (var));
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 08c8541b490..a5a76a497c3 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -173,7 +173,15 @@ determine_value_range (struct loop *loop, tree type, tree var, mpz_t off,
{
minv = minv.max (minc, TYPE_UNSIGNED (type));
maxv = maxv.min (maxc, TYPE_UNSIGNED (type));
- gcc_assert (minv.cmp (maxv, TYPE_UNSIGNED (type)) <= 0);
+ /* If the PHI result range are inconsistent with
+ the VAR range, give up on looking at the PHI
+ results. This can happen if VR_UNDEFINED is
+ involved. */
+ if (minv.cmp (maxv, TYPE_UNSIGNED (type)) > 0)
+ {
+ rtype = get_range_info (var, &minv, &maxv);
+ break;
+ }
}
}
}