From ca7b051775437a3002bdfd9a7d0aebb092095f05 Mon Sep 17 00:00:00 2001 From: Dorit Nuzman Date: Mon, 17 Dec 2007 11:13:56 +0000 Subject: [PATCH] re PR tree-optimization/34445 (internal compiler error: in cost_for_stmt, at tree-vect-transform.c:98) 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 | 6 ++++ gcc/testsuite/ChangeLog | 6 ++++ .../gfortran.dg/vect/cost-model-pr34445.f | 9 ++++++ .../gfortran.dg/vect/cost-model-pr34445a.f | 29 +++++++++++++++++++ gcc/testsuite/gfortran.dg/vect/vect.exp | 6 ++++ gcc/tree-vect-transform.c | 21 +++++++------- 6 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/vect/cost-model-pr34445.f create mode 100644 gcc/testsuite/gfortran.dg/vect/cost-model-pr34445a.f diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4998952678..648cd8fa502 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-12-17 Dorit Nuzman + + 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 PR target/34025 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 282551969b8..bd18305702c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-12-17 Dorit Nuzman + + 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 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 index 00000000000..6e4a2624865 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/cost-model-pr34445.f @@ -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 index 00000000000..aca68bb2039 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/cost-model-pr34445a.f @@ -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" } } diff --git a/gcc/testsuite/gfortran.dg/vect/vect.exp b/gcc/testsuite/gfortran.dg/vect/vect.exp index c48e76fb5c6..a1b949899fc 100644 --- a/gcc/testsuite/gfortran.dg/vect/vect.exp +++ b/gcc/testsuite/gfortran.dg/vect/vect.exp @@ -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" diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c index 09e91b98fdd..8b22dcaf1f4 100644 --- a/gcc/tree-vect-transform.c +++ b/gcc/tree-vect-transform.c @@ -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 -- 2.30.2