From 9b28cb6f0abed5a65534487ca27487675fa4dc18 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 22 Nov 2016 11:13:01 +0100 Subject: [PATCH] re PR middle-end/78445 (ICE in maybe_gen_insn, at optabs.c:7014) PR tree-optimization/78445 * tree-if-conv.c (tree_if_conversion): If any_pred_load_store or any_complicated_phi, version loop even if flag_tree_loop_if_convert is 1. Formatting fix. * gcc.dg/pr78445.c: New test. From-SVN: r242689 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr78445.c | 19 +++++++++++++++++++ gcc/tree-if-conv.c | 23 ++++++++++++++--------- 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr78445.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b8fb5feb289..c97934882eb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-11-22 Jakub Jelinek + + PR tree-optimization/78445 + * tree-if-conv.c (tree_if_conversion): If any_pred_load_store or + any_complicated_phi, version loop even if flag_tree_loop_if_convert is + 1. Formatting fix. + 2016-11-22 Martin Liska PR ipa/78309 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8bba3896ab3..125b01f2817 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-22 Jakub Jelinek + + PR tree-optimization/78445 + * gcc.dg/pr78445.c: New test. + 2016-11-22 Szabolcs Nagy PR libgfortran/78449 diff --git a/gcc/testsuite/gcc.dg/pr78445.c b/gcc/testsuite/gcc.dg/pr78445.c new file mode 100644 index 00000000000..bb5327b9f70 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr78445.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/78445 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-if-convert -ftree-vectorize" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ + +int a; + +void +foo (int x, int *y) +{ + while (a != 0) + if (x != 0) + { + *y = a; + x = *y; + } + else + x = a; +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index dc43d950cf1..13e12c63e1e 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -2808,15 +2808,20 @@ tree_if_conversion (struct loop *loop) goto cleanup; /* Since we have no cost model, always version loops unless the user - specified -ftree-loop-if-convert. Either version this loop, or if - the pattern is right for outer-loop vectorization, version the - outer loop. In the latter case we will still if-convert the - original inner loop. */ - if (flag_tree_loop_if_convert != 1 - && !version_loop_for_if_conversion - (versionable_outer_loop_p (loop_outer (loop)) - ? loop_outer (loop) : loop)) - goto cleanup; + specified -ftree-loop-if-convert or unless versioning is required. + Either version this loop, or if the pattern is right for outer-loop + vectorization, version the outer loop. In the latter case we will + still if-convert the original inner loop. */ + if (any_pred_load_store + || any_complicated_phi + || flag_tree_loop_if_convert != 1) + { + struct loop *vloop + = (versionable_outer_loop_p (loop_outer (loop)) + ? loop_outer (loop) : loop); + if (!version_loop_for_if_conversion (vloop)) + goto cleanup; + } /* Now all statements are if-convertible. Combine all the basic blocks into one huge basic block doing the if-conversion