aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-12-12 10:32:52 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2012-12-12 10:32:52 +0100
commit4c052539b6f9b5c5332d01e7dbc2c04e2477db85 (patch)
treeabacd9867efaa65406be7e3d847cae7417fe04a3 /gcc
parent4e74424074a80791ef6ba223d56b1af3f9ac4439 (diff)
downloadgcc-4c052539b6f9b5c5332d01e7dbc2c04e2477db85.zip
gcc-4c052539b6f9b5c5332d01e7dbc2c04e2477db85.tar.gz
gcc-4c052539b6f9b5c5332d01e7dbc2c04e2477db85.tar.bz2
re PR fortran/55633 (FAIL: gfortran.dg/g77/f90-intrinsic-bit.f -Os execution test)
PR fortran/55633 * tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk): Ignore bounds on which bound += double_int_one overflowed. * gcc.dg/torture/pr55633.c: New test. From-SVN: r194438
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr55633.c39
-rw-r--r--gcc/tree-ssa-loop-niter.c14
4 files changed, 62 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f457101..40405d5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/55633
+ * tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk):
+ Ignore bounds on which bound += double_int_one overflowed.
+
2012-12-11 Eric Botcazou <ebotcazou@adacore.com>
PR target/54121
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2f80e7d..0c8b49f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/55633
+ * gcc.dg/torture/pr55633.c: New test.
+
2012-12-11 Marc Glisse <marc.glisse@inria.fr>
PR c++/53094
diff --git a/gcc/testsuite/gcc.dg/torture/pr55633.c b/gcc/testsuite/gcc.dg/torture/pr55633.c
new file mode 100644
index 0000000..5d30d61
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr55633.c
@@ -0,0 +1,39 @@
+/* PR fortran/55633 */
+/* { dg-do run { target int128 } } */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) void
+bar (__int128_t *x)
+{
+ int c = sizeof (__int128_t) * __CHAR_BIT__;
+ if (c > 127)
+ c = 127;
+ if (*x != c)
+ abort ();
+}
+
+__attribute__((noinline)) void
+foo (void)
+{
+ __int128_t m, ma;
+ ma = 0;
+ m = 0;
+ m = ~m;
+ do
+ {
+ if (m == 0 || ma > 126)
+ break;
+ ma = ma + 1;
+ m = ((__uint128_t) m) >> 1;
+ }
+ while (1);
+ bar (&ma);
+}
+
+int
+main ()
+{
+ foo ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index d3007d7..a9b7077 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3011,7 +3011,12 @@ discover_iteration_bound_by_body_walk (struct loop *loop)
/* Exit terminates loop at given iteration, while non-exits produce undefined
effect on the next iteration. */
if (!elt->is_exit)
- bound += double_int_one;
+ {
+ bound += double_int_one;
+ /* If an overflow occurred, ignore the result. */
+ if (bound.is_zero ())
+ continue;
+ }
if (!loop->any_upper_bound
|| bound.ult (loop->nb_iterations_upper_bound))
@@ -3037,7 +3042,12 @@ discover_iteration_bound_by_body_walk (struct loop *loop)
{
double_int bound = elt->bound;
if (!elt->is_exit)
- bound += double_int_one;
+ {
+ bound += double_int_one;
+ /* If an overflow occurred, ignore the result. */
+ if (bound.is_zero ())
+ continue;
+ }
if (!loop->any_upper_bound
|| bound.ult (loop->nb_iterations_upper_bound))