re PR tree-optimization/92537 (ICE in vect_slp_analyze_node_operations, at tree-vect...
authorRichard Biener <rguenther@suse.de>
Wed, 20 Nov 2019 10:40:09 +0000 (10:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Nov 2019 10:40:09 +0000 (10:40 +0000)
2019-11-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/92537
* tree-vect-slp.c (vect_analyze_slp_instance): Move CTOR
vectorization validity check...
(vect_slp_analyze_operations): ... here.

* gfortran.dg/pr92537.f90: New testcase.

From-SVN: r278494

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr92537.f90 [new file with mode: 0644]
gcc/tree-vect-slp.c

index 45b16058e6bd94375486455c816dd77f55863b40..796056ed9458e4efe93cba6a6b6d2019aed200a6 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92537
+       * tree-vect-slp.c (vect_analyze_slp_instance): Move CTOR
+       vectorization validity check...
+       (vect_slp_analyze_operations): ... here.
+
 2019-11-20  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc-protos.h (make_pass_arc_ifcvt): Declare.
index b9d26f1336259b5bece3e9292afcac994a59002b..a4de5d1e0b730e08365e591054c5696841b4f73c 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92537
+       * gfortran.dg/pr92537.f90: New testcase.
+
 2019-11-20  Christophe Lyon  <christophe.lyon@linaro.org>
 
        * gcc.target/arm/asm-flag-4.c: Replace dg-error with dg-message.
diff --git a/gcc/testsuite/gfortran.dg/pr92537.f90 b/gcc/testsuite/gfortran.dg/pr92537.f90
new file mode 100644 (file)
index 0000000..50dd026
--- /dev/null
@@ -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
index e3bd1dfb3bb8ac0fc0898107e00926b86ed1a260..75d788051c1a3e64c0e59a583caecc456cdb0164 100644 (file)
@@ -2253,18 +2253,6 @@ vect_analyze_slp_instance (vec_info *vinfo,
          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.  */
@@ -2939,7 +2927,12 @@ vect_slp_analyze_operations (vec_info *vinfo)
       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];