+2016-11-21 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/78413
+ * tree-if-conv.c (versionable_outer_loop_p): Require that both
+ inner and outer loop latches have single predecessors.
+
2016-11-21 Georg-Johann Lay <avr@gjlay.de>
PR target/78093
+2016-11-21 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/78413
+ * gcc.dg/tree-ssa/pr78413.c: New test.
+
2016-11-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
* gcc.target/arm/empty_fiq_handler.c: Skip if -mthumb is passed in and
--- /dev/null
+/* PR78413. These previously failed in tree if-conversion due to a loop
+ latch with multiple predecessors that the code did not anticipate. */
+/* { dg-do compile } */
+/* { dg-options "-O3 -ffast-math -fno-strict-aliasing" } */
+
+extern long long int llrint(double x);
+int a;
+double b;
+__attribute__((cold)) void decode_init() {
+ int c, d = 0;
+ for (; d < 12; d++) {
+ if (d)
+ b = 0;
+ c = 0;
+ for (; c < 6; c++)
+ a = b ? llrint(b) : 0;
+ }
+}
+
+struct S {
+ _Bool bo;
+};
+int a, bb, c, d;
+void fn1() {
+ do
+ do
+ do {
+ struct S *e = (struct S *)1;
+ do
+ bb = a / (e->bo ? 2 : 1);
+ while (bb);
+ } while (0);
+ while (d);
+ while (c);
+}
- The loop has a single exit.
- The loop header has a single successor, which is the inner
loop header.
+ - Each of the inner and outer loop latches have a single
+ predecessor.
- The loop exit block has a single predecessor, which is the
inner loop's exit block. */
|| loop->inner->next
|| !single_exit (loop)
|| !single_succ_p (loop->header)
- || single_succ (loop->header) != loop->inner->header)
+ || single_succ (loop->header) != loop->inner->header
+ || !single_pred_p (loop->latch)
+ || !single_pred_p (loop->inner->latch))
return false;
basic_block outer_exit = single_pred (loop->latch);