+2016-11-04 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/78185
+ * loop-invariant.c (find_exits): Record entering inner
+ loops as possibly exiting to handle infinite sub-loops.
+ * tree-ssa-loop-im.c: Include tree-ssa-loop-niter.h.
+ (fill_always_executed_in_1): Honor infinite child loops.
+
2016-11-03 Michael Meissner <meissner@linux.vnet.ibm.com>
PR target/78192
FOR_EACH_EDGE (e, ei, body[i]->succs)
{
- if (flow_bb_inside_loop_p (loop, e->dest))
- continue;
-
- bitmap_set_bit (may_exit, i);
- bitmap_set_bit (has_exit, i);
- outermost_exit = find_common_loop (outermost_exit,
- e->dest->loop_father);
+ if (! flow_bb_inside_loop_p (loop, e->dest))
+ {
+ bitmap_set_bit (may_exit, i);
+ bitmap_set_bit (has_exit, i);
+ outermost_exit = find_common_loop (outermost_exit,
+ e->dest->loop_father);
+ }
+ /* If we enter a subloop that might never terminate treat
+ it like a possible exit. */
+ if (flow_loop_nested_p (loop, e->dest->loop_father))
+ bitmap_set_bit (may_exit, i);
}
continue;
}
+2016-11-04 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/78185
+ * gcc.dg/pr78185.c: New testcase.
+
2016-10-04 David Edelsohn <dje.gcc@gmail.com>
* g++.dg/debug/dwarf2/ref-3.C: XFAIL AIX.
--- /dev/null
+/* { dg-do run { target *-*-linux* *-*-gnu* } } */
+/* { dg-options "-O" } */
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+static char var1 = 0L;
+static char *var2 = &var1;
+
+void do_exit (int i)
+{
+ exit (0);
+}
+
+int main(void)
+{
+ struct sigaction s;
+ sigemptyset (&s.sa_mask);
+ s.sa_handler = do_exit;
+ s.sa_flags = 0;
+ sigaction (SIGALRM, &s, NULL);
+ alarm (1);
+ /* The following loop is infinite, the division by zero should not
+ be hoisted out of it. */
+ for (; (var1 == 0 ? 0 : (100 / var1)) == *var2; );
+ return 0;
+}
#include "trans-mem.h"
#include "gimple-fold.h"
#include "tree-scalar-evolution.h"
+#include "tree-ssa-loop-niter.h"
/* TODO: Support for predicated code motion. I.e.
break;
FOR_EACH_EDGE (e, ei, bb->succs)
- if (!flow_bb_inside_loop_p (loop, e->dest))
- break;
+ {
+ /* If there is an exit from this BB. */
+ if (!flow_bb_inside_loop_p (loop, e->dest))
+ break;
+ /* Or we enter a possibly non-finite loop. */
+ if (flow_loop_nested_p (bb->loop_father,
+ e->dest->loop_father)
+ && ! finite_loop_p (e->dest->loop_father))
+ break;
+ }
if (e)
break;