+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
--- /dev/null
+/* 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;
+}
/* 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))
{
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))