re PR tree-optimization/34445 (internal compiler error: in cost_for_stmt, at tree...
authorDorit Nuzman <dorit@il.ibm.com>
Mon, 17 Dec 2007 11:13:56 +0000 (11:13 +0000)
committerDorit Nuzman <dorit@gcc.gnu.org>
Mon, 17 Dec 2007 11:13:56 +0000 (11:13 +0000)
PR tree-optimization/34445
        * tree-vect-trasnform.c (vect_estimate_min_profitable_iters): Skip
        stmts (including live stmts) that are not relevant.

From-SVN: r131006

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/vect/cost-model-pr34445.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/vect/cost-model-pr34445a.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/vect/vect.exp
gcc/tree-vect-transform.c

index c499895..648cd8f 100644 (file)
@@ -1,3 +1,9 @@
+2007-12-17  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/34445
+       * tree-vect-trasnform.c (vect_estimate_min_profitable_iters): Skip 
+       stmts (including live stmts) that are not relevant.
+
 2007-12-17  Jack Howarth  <howarth@bromo.med.uc.edu>
 
        PR target/34025
index 2825519..bd18305 100644 (file)
@@ -1,3 +1,9 @@
+2007-12-17  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/34445
+       * gfortran.dg/vect/cost-model-pr34445.f: New test.
+       * gfortran.dg/vect/cost-model-pr34445a.f: New test.
+
 2007-12-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/34427
diff --git a/gcc/testsuite/gfortran.dg/vect/cost-model-pr34445.f b/gcc/testsuite/gfortran.dg/vect/cost-model-pr34445.f
new file mode 100644 (file)
index 0000000..6e4a262
--- /dev/null
@@ -0,0 +1,9 @@
+c { dg-do compile }
+      Subroutine FndSph(Alpha,Rad)
+      Dimension Rad(100),RadInp(100)
+      Do I = 1, NSphInp
+        Rad(I) = RadInp(I)
+        Alpha = 1.2
+      End Do
+      End
+c { dg-final { cleanup-tree-dump "vect" } }
diff --git a/gcc/testsuite/gfortran.dg/vect/cost-model-pr34445a.f b/gcc/testsuite/gfortran.dg/vect/cost-model-pr34445a.f
new file mode 100644 (file)
index 0000000..aca68bb
--- /dev/null
@@ -0,0 +1,29 @@
+c { dg-do compile }
+      subroutine derv (xx,b,bv,det,r,s,t,ndopt,cosxy,thick,edis,
+     1                  vni,vnt)
+      implicit real*8 (a-h,o-z)
+      save
+c
+      common /shell1/ disd(9),ield,ielp,npt,idw,ndrot
+      common /shell4/xji(3,3),p(3,32),h(32)
+c
+      dimension xx(3,*),ndopt(*),bv(*),vni(*),cosxy(6,*),vnt(*),
+     1          edis(*),thick(*),b(*)
+c
+      kk=0
+      k2=0
+      do 130 k=1,ield
+      k2=k2 + 3
+      if (ndopt(k)) 127,127,130
+  127 kk=kk + 1
+      do 125 i=1,3
+      b(k2+i)=b(k2+i) + (xji(i,1)*p(1,k) + xji(i,2)*p(2,k))*t
+     1         + xji(i,3)*h(k)
+      th=0.5*thick(kk)
+      b(k2+i+3)=b(k2+i+3) - th*cosxy(i+3,kk)
+  125 b(k2+i+6)=b(k2+i+6) + th*cosxy(i,kk)
+      k2=k2 + 9
+  130 continue
+      return
+      end
+c { dg-final { cleanup-tree-dump "vect" } }
index c48e76f..a1b9498 100644 (file)
@@ -103,6 +103,12 @@ lappend DEFAULT_VECTCFLAGS "-ffast-math"
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-*.\[fF\]{,90,95,03} ]]  \
         "" $DEFAULT_VECTCFLAGS
 
+# -fvect-cost-model tests
+set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
+lappend DEFAULT_VECTCFLAGS "-fvect-cost-model"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cost-model-*.\[fF\]{,90,95,03} ]]  \
+        "" $DEFAULT_VECTCFLAGS
+
 # --param vect-max-version-for-alias-checks=0 tests
 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
 lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
index 09e91b9..8b22dca 100644 (file)
@@ -197,18 +197,19 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo)
        factor = 1;
 
       for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
-        {
-          tree stmt = bsi_stmt (si);
-          stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-          if (!STMT_VINFO_RELEVANT_P (stmt_info)
-              && !STMT_VINFO_LIVE_P (stmt_info))
-            continue;
-          scalar_single_iter_cost += cost_for_stmt (stmt) * factor;
-          vec_inside_cost += STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) * factor;
+       {
+         tree stmt = bsi_stmt (si);
+         stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+         /* Skip stmts that are not vectorized inside the loop.  */
+         if (!STMT_VINFO_RELEVANT_P (stmt_info)
+             && STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def)
+           continue;
+         scalar_single_iter_cost += cost_for_stmt (stmt) * factor;
+         vec_inside_cost += STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) * factor;
          /* FIXME: for stmts in the inner-loop in outer-loop vectorization,
             some of the "outside" costs are generated inside the outer-loop.  */
-          vec_outside_cost += STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info);
-        }
+         vec_outside_cost += STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info);
+       }
     }
 
   /* Add additional cost for the peeled instructions in prologue and epilogue