This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/32131] knowing that stride==1 when using allocated arrays and escaping allocatable arrays
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 May 2007 04:52:21 -0000
- Subject: [Bug fortran/32131] knowing that stride==1 when using allocated arrays and escaping allocatable arrays
- References: <bug-32131-10391@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pinskia at gcc dot gnu dot org 2007-05-29 04:52 -------
(In reply to comment #2)
> PR31738 is another "missed vectorization in Fortran", though I don't think it's
> really that related to this one.
The vectorizer issue just exposes the real issue and maybe why GCC is slow in
some cases (fixing the aliasing issue here will speed up fortran code even
without the vectorizer help). The issue is a.stride is reloaded after the call
to random_number as we think random_number can change the stride. If we change
the code into:
program main
implicit none
real, allocatable, dimension(:) :: a, b, c
real, dimension(10) :: d, e, f
real :: s
integer :: i
allocate (a(10), b(10), c(10))
do i = 0, 10
call random_number(a(i))
call random_number(b(i))
enddo
c = a+b
s = sum(c)
print *,s
call random_number(d)
call random_number(e)
f = d+e
s = sum(f)
print *,f
end program main
We get:
t.f90:18: note: not vectorized: unsupported use in stmt.
t.f90:17: note: LOOP VECTORIZED.
t.f90:13: note: not vectorized: unsupported use in stmt.
t.f90:12: note: Alignment of access forced using peeling.
t.f90:12: note: Vectorizing an unaligned access.
t.f90:12: note: Vectorizing an unaligned access.
t.f90:12: note: LOOP VECTORIZED.
t.f90:8: note: not vectorized: unhandled data-ref
t.f90:1: note: vectorized 2 loops in function.
Which is correct and shows the aliasing issue, we think we change a's stride
which we don't (and cannot in this case).
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32131