From faf4220c7236e48607dd8e286f7f555489d3dbef Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 18 Mar 2015 14:54:12 +0100 Subject: [PATCH] re PR tree-optimization/65450 (Unaligned access with -O3 -mtune=k8) 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 | 6 +++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gfortran.dg/pr65450.f90 | 35 +++++++++++++++++++++++++++ gcc/tree-vect-data-refs.c | 32 +++++++++++++++--------- 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr65450.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 990aa5842a7..0e9955bcdc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2015-03-18 Jakub Jelinek + 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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 406fec06f0e..c4d283c0d95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-03-18 Jakub Jelinek + 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 index 00000000000..700fc64789c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr65450.f90 @@ -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 diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index b308ac7ac68..094275e8439 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -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; -- 2.30.2