Patchwork Fix PR tree-optimization/45714

login
register
mail settings
Submitter Ira Rosen
Date Sept. 19, 2010, 2:24 p.m.
Message ID <OFEEAC493E.4B2641D5-ONC22577A3.003932D3-C22577A3.004F2688@il.ibm.com>
Download mbox | patch
Permalink /patch/65163/
State New
Headers show

Comments

Ira Rosen - Sept. 19, 2010, 2:24 p.m.
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.

Patch

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" } }