From patchwork Sun Sep 19 14:24:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix PR tree-optimization/45714 Date: Sun, 19 Sep 2010 04:24:32 -0000 From: Ira Rosen X-Patchwork-Id: 65163 Message-Id: To: gcc-patches@gcc.gnu.org Hi, When a function call is vectorized, the original scalar statement is replaced with a dummy statement. So, for further accesses we should use the new statement and not the old one. This patch makes this change. Bootstrapped and tested on x86_64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/45714 * tree-vect-stmts.c (vect_transform_stmt): Use a dummy statement created in vectorizable_call instead of the original statement in def stmt updates. testsuite/ChangeLog PR tree-optimization/45714 * gfortran.dg/vect/pr45714-a.f: New test. * gfortran.dg/vect/pr45714-b.f: New test. Index: tree-vect-stmts.c =================================================================== --- tree-vect-stmts.c (revision 164411) +++ tree-vect-stmts.c (working copy) @@ -4516,7 +4516,7 @@ vect_transform_stmt (gimple stmt, gimple bool is_store = false; gimple vec_stmt = NULL; stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - gimple orig_stmt_in_pattern; + gimple orig_stmt_in_pattern, orig_scalar_stmt = stmt; bool done; switch (STMT_VINFO_TYPE (stmt_info)) @@ -4584,6 +4584,7 @@ vect_transform_stmt (gimple stmt, gimple case call_vec_info_type: gcc_assert (!slp_node); done = vectorizable_call (stmt, gsi, &vec_stmt); + stmt = gsi_stmt (*gsi); break; case reduc_vec_info_type: @@ -4662,7 +4663,8 @@ vect_transform_stmt (gimple stmt, gimple documentation of vect_pattern_recog. */ if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo)) { - gcc_assert (STMT_VINFO_RELATED_STMT (stmt_vinfo) == stmt); + gcc_assert (STMT_VINFO_RELATED_STMT (stmt_vinfo) + == orig_scalar_stmt); STMT_VINFO_VEC_STMT (stmt_vinfo) = vec_stmt; } } Index: testsuite/gfortran.dg/vect/pr45714-a.f =================================================================== --- testsuite/gfortran.dg/vect/pr45714-a.f (revision 0) +++ testsuite/gfortran.dg/vect/pr45714-a.f (revision 0) @@ -0,0 +1,27 @@ +! { dg-do compile { target x86_64-*-* } } +! { dg-options "-O3 -march=core2 -mavx -ffast-math -mveclibabi=svml" } + + integer index(18),i,j,k,l,ipiv(18),info,ichange,neq,lda,ldb, + & nrhs,iplas + real*8 ep0(6),al10(18),al20(18),dg0(18),ep(6),al1(18), + & al2(18),dg(18),ddg(18),xm(6,18),h(18,18),ck(18),cn(18), + & c(18),d(18),phi(18),delta(18),r0(18),q(18),b(18),cphi(18), + & q1(18),q2(18),stri(6),htri(18),sg(18),r(42),xmc(6,18),aux(18), + & t(42),gl(18,18),gr(18,18),ee(6),c1111,c1122,c1212,dd, + & skl(3,3),xmtran(3,3),ddsdde(6,6),xx(6,18) + do + do i=1,18 + htri(i)=dabs(sg(i))-r0(i)-ck(i)*(dg(i)/dtime)**(1.d0/cn(i)) + do j=1,18 + enddo + enddo + do + if(i.ne.j) then + gr(index(i),1)=htri(i) + endif + call dgesv(neq,nrhs,gl,lda,ipiv,gr,ldb,info) + enddo + enddo + end + +! { dg-final { cleanup-tree-dump "vect" } } Index: testsuite/gfortran.dg/vect/pr45714-b.f =================================================================== --- testsuite/gfortran.dg/vect/pr45714-b.f (revision 0) +++ testsuite/gfortran.dg/vect/pr45714-b.f (revision 0) @@ -0,0 +1,27 @@ +! { dg-do compile { target powerpc*-*-* } } +! { dg-options "-O3 -mcpu=power7 -ffast-math -mveclibabi=mass" } + + integer index(18),i,j,k,l,ipiv(18),info,ichange,neq,lda,ldb, + & nrhs,iplas + real*8 ep0(6),al10(18),al20(18),dg0(18),ep(6),al1(18), + & al2(18),dg(18),ddg(18),xm(6,18),h(18,18),ck(18),cn(18), + & c(18),d(18),phi(18),delta(18),r0(18),q(18),b(18),cphi(18), + & q1(18),q2(18),stri(6),htri(18),sg(18),r(42),xmc(6,18),aux(18), + & t(42),gl(18,18),gr(18,18),ee(6),c1111,c1122,c1212,dd, + & skl(3,3),xmtran(3,3),ddsdde(6,6),xx(6,18) + do + do i=1,18 + htri(i)=dabs(sg(i))-r0(i)-ck(i)*(dg(i)/dtime)**(1.d0/cn(i)) + do j=1,18 + enddo + enddo + do + if(i.ne.j) then + gr(index(i),1)=htri(i) + endif + call dgesv(neq,nrhs,gl,lda,ipiv,gr,ldb,info) + enddo + enddo + end + +! { dg-final { cleanup-tree-dump "vect" } }