Fortran subroutine arguments should be marked as
__restrict__. Currently, the following code isn't
$ cat loopsum.f90
real, dimension(n), intent(in) :: a,b
real, dimension(n), intent(out) :: c
c(i) = a(i)+b(i)
$ gfortran -O -S -ftree-vectorize -ftree-vectorizer-verbose=5 loopsum.f90
loopsum.f90:4: note: not vectorized: can't determine dependence between: (*a_18)
[D.527_17] and (*c_25)[D.527_17]
loopsum.f90:1: note: vectorized 0 loops in function.
$ gfortran -v
Using built-in specs.
Configured with: ../gcc-4.1-20050508/configure --prefix=/home/zfkts --enable-
Thread model: posix
gcc version 4.1.0 20050508 (experimental)
Actually -fargument-noalias-global is set to true for fortran and should be respected instead of
marking them as restrict.
If the aliasing information is correct on the VOPS, I would assume that the vectorizer would not have
problems with it.
Note there is another bug about this option, see PR 17064.
I have a fix which I need to bootstrap/test.
Talked to Daniel Berlin about the patch I had, it was in the wrong spot, I had it in the post process and not when analyzing the code. So unassigning for now.
I have a fix which comes from Richard Guenther and modified for -fargument-noalias-global instead of restrict as it was using the wrong test.
Patch posted: http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00864.html
Subject: Bug 21470
Date: Thu Jan 26 17:51:25 2006
New Revision: 110263
2006-01-26 Richard Guenther <email@example.com>
Andrew Pinski <firstname.lastname@example.org>
partial PR tree-opt/17064
* tree-ssa-structalias.c (intra_create_variable_infos):
Create heap variables for incoming parameters if
flag_argument_noalias > 1.
(find_what_p_points_to): Look through default defs of