[Bug middle-end/36099] New: [4.4 Regression] early loop unrolling pass prevents vectorization

dominiq at lps dot ens dot fr gcc-bugzilla@gcc.gnu.org
Thu May 1 14:17:00 GMT 2008


The following test case does not vectorize:

integer, parameter :: n = 1000000
integer  :: i, j, k
real(8)  :: pi, sum1, sum2, theta, phi, sini, cosi, dotp
real(8)  :: a(3), b(9,3), c(3)
pi = acos(-1.0d0)
theta = pi/9.0d0
phi = pi/4.5d0
do k = 1, 9
   b(k,1) = 0.5d0*cos(k*phi)*sin(k*theta)
   b(k,2) = 0.5d0*sin(k*phi)*sin(k*theta)
   b(k,3) = 0.5d0*cos(k*theta)
end do
theta = pi/real(n,kind=8)
sum2 = 0.0
do i = 1, n
    sini = sin(i*theta)
    cosi = cos(i*theta)
    phi = pi/4.5d0
    sum1 = 0.0d0
    do j = 1, 9
        c(1) = 0.5d0*cos(j*phi)*sini
        c(2) = 0.5d0*sin(j*phi)*sini
        c(3) = 0.5d0*cosi
        do k =1, 9
           a(1) = b(k,1) - c(1)
           a(2) = b(k,2) - c(2)
           a(3) = b(k,3) - c(3)
!           a = b(k,:) - c
           dotp = a(1)*a(1) + a(2)*a(2) + a(3)*a(3)
!           dotp = dot_product(a,a)
           sum1 = sum1 +dotp
        end do
    end do
    sum2 = sum2 + sum1/81.0d0
end do
print *, 3.0d0*sum2/(4.0d0*pi*real(n,kind=8))
end

[ibook-dhum] bug/timing% gfc -O3 -ffast-math -funroll-loops -ftree-loop-linear
-ftree-vectorizer-verbose=2 test_vect.f90
test_vect.f90:20: note: not vectorized: unsupported data-type complex(kind=8)
test_vect.f90:8: note: not vectorized: unsupported data-type complex(kind=8)
test_vect.f90:1: note: vectorized 0 loops in function.

while it vectorize for

        do k =1, 9
!           a(1) = b(k,1) - c(1)
!           a(2) = b(k,2) - c(2)
!           a(3) = b(k,3) - c(3)
           a = b(k,:) - c
           dotp = a(1)*a(1) + a(2)*a(2) + a(3)*a(3)
!           dotp = dot_product(a,a)
           sum1 = sum1 +dotp
        end do

[ibook-dhum] bug/timing% gfc -O3 -ffast-math -funroll-loops -ftree-loop-linear
-ftree-vectorizer-verbose=2 test_vect.f90
test_vect.f90:24: note: LOOP VECTORIZED.
test_vect.f90:8: note: not vectorized: unsupported data-type complex(kind=8)
test_vect.f90:1: note: vectorized 1 loops in function.

(see http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00033.html and pr34265).

Note that both variants do not vectorize on powerpc-apple-darwin9.


-- 
           Summary: [4.4 Regression] early loop unrolling pass prevents
                    vectorization
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr
 GCC build triplet: i686-apple-darwin9
  GCC host triplet: i686-apple-darwin9
GCC target triplet: i686-apple-darwin9


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



More information about the Gcc-bugs mailing list