re PR tree-optimization/87665 (gcc HEAD (svn: 265340) breaks elements on resize)
authorRichard Biener <rguenther@suse.de>
Thu, 25 Oct 2018 08:59:07 +0000 (08:59 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 25 Oct 2018 08:59:07 +0000 (08:59 +0000)
2018-10-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87665
PR tree-optimization/87745
* tree-vectorizer.h (get_earlier_stmt): Remove.
(get_later_stmt): Pick up UID from the original non-pattern stmt.

* gfortran.dg/20181025-1.f: New testcase.

From-SVN: r265481

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/20181025-1.f [new file with mode: 0644]
gcc/tree-vectorizer.h

index fadba61c1df700087d87ec95e73df683fd021161..ea92a4286cc0539dec2fc84f2246e1a2094394dc 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87665
+       PR tree-optimization/87745
+       * tree-vectorizer.h (get_earlier_stmt): Remove.
+       (get_later_stmt): Pick up UID from the original non-pattern stmt.
+
 2018-10-25  Sam Tebbs  <sam.tebbs@arm.com>
 
        * options.texi (Deprecated): Move list to Var section.
index 94496cd30a7fde61e4a745264fe14f8a6dcb2f5d..6a50e92905bec3112aa12911121f7a6d223deffa 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87665
+       PR tree-optimization/87745
+       * gfortran.dg/20181025-1.f: New testcase.
+
 2018-10-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/87725
diff --git a/gcc/testsuite/gfortran.dg/20181025-1.f b/gcc/testsuite/gfortran.dg/20181025-1.f
new file mode 100644 (file)
index 0000000..1acbd72
--- /dev/null
@@ -0,0 +1,28 @@
+! { dg-do compile }
+! { dg-options "-Ofast" }
+! { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } }
+      SUBROUTINE FOO(EF3,CA,ZA,NATA,IC4,NFRGPT)
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
+      PARAMETER (MXATM=500)
+      COMMON DE(3,MXATM)
+      DIMENSION CA(3,NATA)
+      DIMENSION ZA(NATA)
+      DIMENSION EF3(3,NFRGPT)
+      DO II = 1,NATA
+         XII = XJ - CA(1,II)
+         YII = YJ - CA(2,II)
+         ZII = ZJ - CA(3,II)
+         RJII = SQRT(XII*XII + YII*YII + ZII*ZII)
+         R3 = RJII*RJII*RJII
+         IF (IC4.EQ.0) THEN
+            DE(1,II) = DE(1,II) - S2*ZA(II)*XII/R3
+            DE(2,II) = DE(2,II) - S2*ZA(II)*YII/R3
+            DE(3,II) = DE(3,II) - S2*ZA(II)*ZII/R3
+         ELSE 
+            EF3(1,IC4+II) = EF3(1,IC4+II) - S2*ZA(II)*XII/R3
+            EF3(2,IC4+II) = EF3(2,IC4+II) - S2*ZA(II)*YII/R3
+            EF3(3,IC4+II) = EF3(3,IC4+II) - S2*ZA(II)*ZII/R3
+         END IF
+      END DO
+      RETURN
+      END           
index 988456808318dabd0058f6b0d038f8c272e75c6b..08d696a2f7c85c784e8c64f7c157d5fedcb0719d 100644 (file)
@@ -1085,38 +1085,6 @@ nested_in_vect_loop_p (struct loop *loop, stmt_vec_info stmt_info)
          && (loop->inner == (gimple_bb (stmt_info->stmt))->loop_father));
 }
 
-/* Return the earlier statement between STMT1_INFO and STMT2_INFO.  */
-
-static inline stmt_vec_info
-get_earlier_stmt (stmt_vec_info stmt1_info, stmt_vec_info stmt2_info)
-{
-  gcc_checking_assert ((STMT_VINFO_IN_PATTERN_P (stmt1_info)
-                       || !STMT_VINFO_RELATED_STMT (stmt1_info))
-                      && (STMT_VINFO_IN_PATTERN_P (stmt2_info)
-                          || !STMT_VINFO_RELATED_STMT (stmt2_info)));
-
-  if (gimple_uid (stmt1_info->stmt) < gimple_uid (stmt2_info->stmt))
-    return stmt1_info;
-  else
-    return stmt2_info;
-}
-
-/* Return the later statement between STMT1_INFO and STMT2_INFO.  */
-
-static inline stmt_vec_info
-get_later_stmt (stmt_vec_info stmt1_info, stmt_vec_info stmt2_info)
-{
-  gcc_checking_assert ((STMT_VINFO_IN_PATTERN_P (stmt1_info)
-                       || !STMT_VINFO_RELATED_STMT (stmt1_info))
-                      && (STMT_VINFO_IN_PATTERN_P (stmt2_info)
-                          || !STMT_VINFO_RELATED_STMT (stmt2_info)));
-
-  if (gimple_uid (stmt1_info->stmt) > gimple_uid (stmt2_info->stmt))
-    return stmt1_info;
-  else
-    return stmt2_info;
-}
-
 /* Return TRUE if a statement represented by STMT_INFO is a part of a
    pattern.  */
 
@@ -1137,6 +1105,18 @@ vect_orig_stmt (stmt_vec_info stmt_info)
   return stmt_info;
 }
 
+/* Return the later statement between STMT1_INFO and STMT2_INFO.  */
+
+static inline stmt_vec_info
+get_later_stmt (stmt_vec_info stmt1_info, stmt_vec_info stmt2_info)
+{
+  if (gimple_uid (vect_orig_stmt (stmt1_info)->stmt)
+      > gimple_uid (vect_orig_stmt (stmt2_info)->stmt))
+    return stmt1_info;
+  else
+    return stmt2_info;
+}
+
 /* If STMT_INFO has been replaced by a pattern statement, return the
    replacement statement, otherwise return STMT_INFO itself.  */