This backport contains 1 patch from gcc main stream tree. The commit id of these patchs list as following in the order of time. 0001-re-PR-tree-optimization-92537-ICE-in-vect_slp_analyz.patch 2439d584d5def75d705f33218bb3b97fca4c11a1 diff -Nurp a/gcc/testsuite/gfortran.dg/pr92537.f90 b/gcc/testsuite/gfortran.dg/pr92537.f90 --- a/gcc/testsuite/gfortran.dg/pr92537.f90 1970-01-01 08:00:00.000000000 +0800 +++ b/gcc/testsuite/gfortran.dg/pr92537.f90 2020-09-03 16:53:43.024000000 +0800 @@ -0,0 +1,32 @@ +! { dg-do compile } +! { dg-options "-O2 -ftree-vectorize -fno-inline" } +! { dg-additional-options "-march=skylake" { target x86_64-*-* i?86-*-* } } +MODULE pr93527 + implicit none + integer, parameter :: wp = kind (1.d0) + interface p_min + module procedure p_min_wp + end interface +contains + subroutine foo (pr) + real(wp), pointer :: pr(:) + integer :: nzd + real(wp) :: pmin + real(wp) :: pmin_diag + integer :: i + nzd = 15 + allocate (pr(nzd)) + pmin_diag = 4000._wp + pmin = p_min(pmin_diag) + pmin = min (pmin,pmin_diag) + pr(1) = log(pmin) + do i=1,nzd-1 + pr(i+1) = log(pmin) + i + end do + end subroutine foo + function p_min_wp (x) result (p_min) + real(wp), intent(in) :: x + real(wp) :: p_min + p_min = x + end function p_min_wp +end module pr93527 diff -Nurp a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c --- a/gcc/tree-vect-slp.c 2020-09-03 16:53:22.668000000 +0800 +++ b/gcc/tree-vect-slp.c 2020-09-03 16:53:43.024000000 +0800 @@ -2176,18 +2176,6 @@ vect_analyze_slp_instance (vec_info *vin matches[group_size / const_max_nunits * const_max_nunits] = false; vect_free_slp_tree (node, false); } - else if (constructor - && SLP_TREE_DEF_TYPE (node) != vect_internal_def) - { - /* CONSTRUCTOR vectorization relies on a vector stmt being - generated, that doesn't work for fully external ones. */ - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "Build SLP failed: CONSTRUCTOR of external " - "or constant elements\n"); - vect_free_slp_tree (node, false); - return false; - } else { /* Create a new SLP instance. */ @@ -2872,7 +2860,12 @@ vect_slp_analyze_operations (vec_info *v if (!vect_slp_analyze_node_operations (vinfo, SLP_INSTANCE_TREE (instance), instance, visited, lvisited, - &cost_vec)) + &cost_vec) + /* Instances with a root stmt require vectorized defs for the + SLP tree root. */ + || (SLP_INSTANCE_ROOT_STMT (instance) + && (SLP_TREE_DEF_TYPE (SLP_INSTANCE_TREE (instance)) + != vect_internal_def))) { slp_tree node = SLP_INSTANCE_TREE (instance); stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0];