http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56933



             Bug #: 56933

           Summary: [4.9 Regression] Vectorizer missing read-write

                    dependency for interleaved accesses

    Classification: Unclassified

           Product: gcc

           Version: 4.9.0

            Status: UNCONFIRMED

          Keywords: wrong-code

          Severity: normal

          Priority: P3

         Component: tree-optimization

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: wschm...@gcc.gnu.org

                CC: berg...@gcc.gnu.org, d...@gcc.gnu.org,

                    rgue...@gcc.gnu.org

              Host: powerpc*-*-*

            Target: powerpc*-*-*

             Build: powerpc*-*-*





Created attachment 29861

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29861

Vectorization details dump for the test case



vect_analyze_group_access() in tree-vect-data-refs.c contains a test for

load-store dependencies:



              if (GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (next))

                  || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))



Currently this always returns false because this field has not yet been set in

the vinfo.  This began with r196872, where the code to analyze accesses was

moved ahead of the code to analyze dependences.



I put together a test demonstrating that it's possible for us to generate

incorrect code as a result:



       subroutine test(a,b,c,d,e,f)

       integer k

       real*4, intent(out) :: a(1000)

       real*4, intent(out) :: b(1000)

       real*4, intent(in) :: c(1000)

       real*4, intent(inout) :: d(2000)

       real*4, intent(out) :: e(1000)

       real*4, intent(out) :: f(1000)



       do k = 1,1000

          a(k) = 3.0 * d(2*k)

          e(k) = 3.3 * d(2*k+1)

          d(2*k) = 2.0 * c(k)

          d(2*k+1) = 2.3 * c(k)

          b(k) = d(2*k) - 5.5;

          f(k) = d(2*k+1) + 5.5;

       enddo



       return

       end



I'm attaching a detailed dump of the vectorization pass that shows that the

values of d(2*k) and d(2*k+1) used to compute b(k) and f(k) are the ones loaded

prior to the stores to those locations.



To reproduce on powerpc64-unknown-linux-gnu:



$ gfortran -O3 -ffast-math -mcpu=power7 -fno-vect-cost-model interl-lsl-2.f

Reply via email to