]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/117060 - fix oversight in vect_build_slp_tree_1
authorRichard Biener <rguenther@suse.de>
Thu, 10 Oct 2024 12:15:13 +0000 (14:15 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 10 Oct 2024 13:26:17 +0000 (15:26 +0200)
We are failing to match call vs. non-call when dealing with matching
loads or stores.

PR tree-optimization/117060
* tree-vect-slp.cc (vect_build_slp_tree_1): When comparing
calls also fail if the first isn't a call.

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

gcc/testsuite/gfortran.dg/pr117060.f90 [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/gfortran.dg/pr117060.f90 b/gcc/testsuite/gfortran.dg/pr117060.f90
new file mode 100644 (file)
index 0000000..50004e1
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! { dg-options "-O2" }
+
+subroutine foo (out)
+
+implicit none
+
+real    :: out(*)
+integer :: i,k
+real    :: a(100)
+real    :: b(100)
+
+k = 0
+do i = 1, 10
+  k = k + 1
+  out(k) = a(i)
+  k = k + 1
+  out(k) = sqrt((a(3*i)-b(4))**2 + (a(3*i+1)-b(4+1))**2)
+end do
+
+end subroutine
index 8b53b0fdb16dd2deee15393bd97a0327934d65fd..9bf6ae4ec8e0635cf914fb5d703ed548bd446b20 100644 (file)
@@ -1367,8 +1367,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
              && first_stmt_code != CFN_MASK_LOAD
              && first_stmt_code != CFN_MASK_STORE)
            {
-             if (!compatible_calls_p (as_a <gcall *> (stmts[0]->stmt),
-                                      call_stmt))
+             if (!is_a <gcall *> (stmts[0]->stmt)
+                 || !compatible_calls_p (as_a <gcall *> (stmts[0]->stmt),
+                                         call_stmt))
                {
                  if (dump_enabled_p ())
                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,