re PR tree-optimization/65450 (Unaligned access with -O3 -mtune=k8)
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 Mar 2015 13:54:12 +0000 (14:54 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 18 Mar 2015 13:54:12 +0000 (14:54 +0100)
PR tree-optimization/65450
* tree-vect-data-refs.c (vect_duplicate_ssa_name_ptr_info): New
function.
(vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr): Use
it instead of duplicate_ssa_name_ptr_info.

* gfortran.dg/pr65450.f90: New test.

From-SVN: r221490

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

index 990aa5842a747fbe3c403f481c5298c78c3bfe05..0e9955bcdc49dcbd7afd2144a947bc5bcf415568 100644 (file)
@@ -1,5 +1,11 @@
 2015-03-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/65450
+       * tree-vect-data-refs.c (vect_duplicate_ssa_name_ptr_info): New
+       function.
+       (vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr): Use
+       it instead of duplicate_ssa_name_ptr_info.
+
        PR target/65222
        * doc/invoke.texi: Add knl as x86 -march=/-mtune= CPU type.
 
index 406fec06f0ef7ed08d3dad11875ea74eceed121b..c4d283c0d95fd117996b7a7ac1cde76b03253d16 100644 (file)
@@ -1,5 +1,8 @@
 2015-03-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/65450
+       * gfortran.dg/pr65450.f90: New test.
+
        PR target/65078
        * gcc.target/i386/pr65078-1.c: New test.
        * gcc.target/i386/pr65078-2.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr65450.f90 b/gcc/testsuite/gfortran.dg/pr65450.f90
new file mode 100644 (file)
index 0000000..700fc64
--- /dev/null
@@ -0,0 +1,35 @@
+! PR tree-optimization/65450
+! { dg-do run }
+! { dg-additional-options "-mtune=amdfam10" { target x86_64-*-* i?86-*-* } }
+
+program pr65450
+  integer :: n, m, o, i, k
+  double precision :: u(500,60,3), h(500,60,3)
+  double precision :: v(500,60)
+  u = 0
+  h = 0
+  o = 1
+  m = 2
+  n = 3
+  do k = 1, 50
+    v = foo (u(:,:,m))
+    u(2:499,1:60,n) = u(2:499,1:60,o)+16.d0
+    h(1:500,2:59,n) = h(1:500,2:59,o)-4.d0*v(1:500,2:59)-32.0d0
+    i = o
+    o = m
+    m = n
+    n = i
+  end do
+  if (abs (v(17, 23) + h(17, 23, 2) + 768.0d0) > 0.5d0) call abort
+contains
+  function foo(a)
+    double precision :: a(:,:)
+    double precision :: foo(size(a,dim=1),size(a,dim=2))
+    integer :: i, j
+    i = size(a,dim=1)
+    j = size(a,dim=2)
+    foo(2:i-1,1:j) = a(3:i,1:j)-a(1:i-2,1:j)
+    foo(1,1:j) = 2*(a(2,1:j)-a(1,1:j))
+    foo(i,1:j) = 2*(a(i,1:j)-a(i-1,1:j))
+  end function foo
+end program pr65450
index b308ac7ac680b365d58c1b0d13f6bd0786d0132b..094275e84394384c39f74457cebf8c0afde8f3b2 100644 (file)
@@ -3845,6 +3845,20 @@ vect_get_new_vect_var (tree type, enum vect_var_kind var_kind, const char *name)
   return new_vect_var;
 }
 
+/* Duplicate ptr info and set alignment/misaligment on NAME from DR.  */
+
+static void
+vect_duplicate_ssa_name_ptr_info (tree name, data_reference *dr,
+                                 stmt_vec_info stmt_info)
+{
+  duplicate_ssa_name_ptr_info (name, DR_PTR_INFO (dr));
+  unsigned int align = TYPE_ALIGN_UNIT (STMT_VINFO_VECTYPE (stmt_info));
+  int misalign = DR_MISALIGNMENT (dr);
+  if (misalign == -1)
+    mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (name));
+  else
+    set_ptr_info_alignment (SSA_NAME_PTR_INFO (name), align, misalign);
+}
 
 /* Function vect_create_addr_base_for_vector_ref.
 
@@ -3964,13 +3978,9 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
   if (DR_PTR_INFO (dr)
       && TREE_CODE (addr_base) == SSA_NAME)
     {
-      duplicate_ssa_name_ptr_info (addr_base, DR_PTR_INFO (dr));
-      unsigned int align = TYPE_ALIGN_UNIT (STMT_VINFO_VECTYPE (stmt_info));
-      int misalign = DR_MISALIGNMENT (dr);
-      if (offset || byte_offset || (misalign == -1))
+      vect_duplicate_ssa_name_ptr_info (addr_base, dr, stmt_info);
+      if (offset || byte_offset)
        mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (addr_base));
-      else
-       set_ptr_info_alignment (SSA_NAME_PTR_INFO (addr_base), align, misalign);
     }
 
   if (dump_enabled_p ())
@@ -4210,7 +4220,7 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
       aggr_ptr_init = make_ssa_name (aggr_ptr, vec_stmt);
       /* Copy the points-to information if it exists. */
       if (DR_PTR_INFO (dr))
-       duplicate_ssa_name_ptr_info (aggr_ptr_init, DR_PTR_INFO (dr));
+       vect_duplicate_ssa_name_ptr_info (aggr_ptr_init, dr, stmt_info);
       gimple_assign_set_lhs (vec_stmt, aggr_ptr_init);
       if (pe)
        {
@@ -4253,8 +4263,8 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
       /* Copy the points-to information if it exists. */
       if (DR_PTR_INFO (dr))
        {
-         duplicate_ssa_name_ptr_info (indx_before_incr, DR_PTR_INFO (dr));
-         duplicate_ssa_name_ptr_info (indx_after_incr, DR_PTR_INFO (dr));
+         vect_duplicate_ssa_name_ptr_info (indx_before_incr, dr, stmt_info);
+         vect_duplicate_ssa_name_ptr_info (indx_after_incr, dr, stmt_info);
        }
       if (ptr_incr)
        *ptr_incr = incr;
@@ -4283,8 +4293,8 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
       /* Copy the points-to information if it exists. */
       if (DR_PTR_INFO (dr))
        {
-         duplicate_ssa_name_ptr_info (indx_before_incr, DR_PTR_INFO (dr));
-         duplicate_ssa_name_ptr_info (indx_after_incr, DR_PTR_INFO (dr));
+         vect_duplicate_ssa_name_ptr_info (indx_before_incr, dr, stmt_info);
+         vect_duplicate_ssa_name_ptr_info (indx_after_incr, dr, stmt_info);
        }
       if (ptr_incr)
        *ptr_incr = incr;