From b614fca25fac28542b8c6b2df3862688b96e0581 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 21 Jun 2019 11:10:39 +0000 Subject: [PATCH] re PR tree-optimization/90913 (ICE in maybe_gen_insn, at optabs.c:7341 since r272239) 2019-06-21 Richard Biener PR tree-optimization/90913 * tree-vect-loop-manip.c (vect_loop_versioning): Do not re-use the scalar variant of if-conversion versioning. * gfortran.dg/vect/pr90913.f90: New testcase. From-SVN: r272545 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/vect/pr90913.f90 | 22 ++++++++++++++++++++++ gcc/tree-vect-loop-manip.c | 7 +++++-- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/vect/pr90913.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a6b86bd266..0c75a0f687e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-06-21 Richard Biener + + PR tree-optimization/90913 + * tree-vect-loop-manip.c (vect_loop_versioning): Do not re-use + the scalar variant of if-conversion versioning. + 2019-06-21 Jakub Jelinek * omp-low.c (lower_rec_simd_input_clauses): Add rvar2 argument, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c5bb4508539..8181bcd752e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-21 Richard Biener + + PR tree-optimization/90913 + * gfortran.dg/vect/pr90913.f90: New testcase. + 2019-06-21 Jakub Jelinek * gcc.dg/vect/vect-simd-12.c: New test. diff --git a/gcc/testsuite/gfortran.dg/vect/pr90913.f90 b/gcc/testsuite/gfortran.dg/vect/pr90913.f90 new file mode 100644 index 00000000000..d0f225159cc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/pr90913.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! { dg-options "-O3 -ffast-math" } +! { dg-additional-options "-mavx -mveclibabi=svml" { target i?86-*-* x86_64-*-* } } +subroutine foo (a, b, c, d, e, f, g, h, k, l) + implicit none + integer :: d, e, f, g, i, j + real :: a, b(5,6), c(6), h(6,10,5), k(5,10,2), l(10,5), m, n, o + do i=1,5 + do j=1,6 + m=l(f,g)*log(c(j)) + if (m<2) then + if (m<-2) then + h(j,f,g)=n + else + h(j,f,g)=o + endif + endif + b(i,j)=a+k(i,d,e)+k(i,1,e)**h(j,f,g) + enddo + enddo + write(*,'()') +end diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 9cf1d48bda0..c5cabc8633b 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -3095,9 +3095,12 @@ vect_loop_versioning (loop_vec_info loop_vinfo, } /* Apply versioning. If there is already a scalar version created by - if-conversion re-use that. */ + if-conversion re-use that. Note we cannot re-use the copy of + an if-converted outer-loop when vectorizing the inner loop only. */ gcond *cond; - if (gimple *call = vect_loop_vectorized_call (loop_to_version, &cond)) + gimple *call; + if ((!loop_to_version->inner || loop == loop_to_version) + && (call = vect_loop_vectorized_call (loop_to_version, &cond))) { gcc_assert (scalar_loop); condition_bb = gimple_bb (cond); -- 2.30.2