Fortran subroutine arguments should be marked as __restrict__. Currently, the following code isn't vectorized: $ cat loopsum.f90 subroutine foo(a,b,c,n) real, dimension(n), intent(in) :: a,b real, dimension(n), intent(out) :: c do i=1,n c(i) = a(i)+b(i) end do end $ 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. Target: ia64-unknown-linux-gnu Configured with: ../gcc-4.1-20050508/configure --prefix=/home/zfkts --enable- languages=c,f95 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
Fixed applied.
Subject: Bug 21470 Author: pinskia Date: Thu Jan 26 17:51:25 2006 New Revision: 110263 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110263 Log: 2006-01-26 Richard Guenther <rguenther@suse.de> Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/21470 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 parameter decls. Modified: trunk/gcc/ChangeLog