On 11 November 2011 17:32, Jakub Jelinek <ja...@redhat.com> wrote: > Hi!
Hi, > > Removing the scalar call in vectorizable_call for SLP vectorization > is too early, when another SLP instance refers to the same scalar call, > we'll ICE because that stmt doesn't have bb anymore or gsi_for_stmt > doesn't succeed for it. > > Fixed by postponing replacement of calls with zeroing of lhs for later > in the SLP case. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2011-11-11 Jakub Jelinek <ja...@redhat.com> > > PR tree-optimization/51058 > * tree-vect-slp.c (vect_remove_slp_scalar_calls): New function. > (vect_schedule_slp): Call it. > * tree-vect-stmts.c (vectorizable_call): If slp_node != NULL, > don't replace scalar calls with clearing of their lhs here. I think it's rhs. > > * gcc.dg/vect/fast-math-vect-call-1.c: Add f4 test. > * gfortran.fortran-torture/compile/pr51058.f90: New test. > > --- gcc/tree-vect-slp.c.jj 2011-11-10 18:09:12.000000000 +0100 > +++ gcc/tree-vect-slp.c 2011-11-11 13:18:42.157292895 +0100 > @@ -2898,6 +2898,46 @@ vect_schedule_slp_instance (slp_tree nod > return is_store; > } > > +/* Replace scalar calls from SLP node NODE with clearing of their lhs. Here too. > + For loop vectorization this is done in vectorizable_call, but for SLP > + it needs to be deferred until end of vect_schedule_slp, because multiple > + SLP instances may refer to the same scalar stmt. */ > + > +static void > +vect_remove_slp_scalar_calls (slp_tree node) > +{ ... > --- gcc/testsuite/gfortran.fortran-torture/compile/pr51058.f90.jj > 2011-11-11 13:26:14.665615842 +0100 > +++ gcc/testsuite/gfortran.fortran-torture/compile/pr51058.f90 2011-11-11 > 13:25:50.000000000 +0100 > @@ -0,0 +1,18 @@ > +! PR tree-optimization/51058 > +! { dg-do compile } > +subroutine pr51058(n, u, v, w, z) > + double precision :: x(3,-2:16384), y(3,-2:16384), b, u, v, w, z > + integer :: i, n > + common /c/ x, y > + do i = 1, n > + b = u * int(x(1,i)) + sign(z,x(1,i)) > + x(1,i) = x(1,i) - b > + y(1,i) = y(1,i) - b > + b = v * int(x(2,i)) + sign(z,x(2,i)) > + x(2,i) = x(2,i) - b > + y(2,i) = y(2,i) - b > + b = w * int(x(3,i)) + sign(z,x(3,i)) > + x(3,i) = x(3,i) - b > + y(3,i) = y(3,i) - b > + end do > +end subroutine Please add ! { dg-final { cleanup-tree-dump "vect" } } OK otherwise. Thanks, Ira > > Jakub >