------- Comment #24 from dominiq at lps dot ens dot fr 2009-12-20 12:46 ------- > The code that now gets vectorized is the summation of array 'reduce': > sum(reduce). It looks like the problem is with adding the reduction result to > the correct index of 'temp' (scalar code), and not with the reduction itself. > Could you please verify that by printing the reduction result?
I have changed the code to: program where_2 integer temp(10), reduce(10), tmp(10) temp = 10 reduce(1:3) = -1 reduce(4:6) = 0 reduce(7:8) = 5 reduce(9:10) = 10 tmp = 0 WHERE (reduce < 0) temp = 100 ELSE WHERE (reduce .EQ. 0) temp = 200 + temp ELSE WHERE WHERE (reduce > 6) tmp = sum(reduce) temp = 300 + temp + tmp END WHERE print *, temp print *, tmp if (any (temp .ne. (/100, 100, 100, 210, 210, 210, 310, 310, 337, 337/))) & call abort end program And with r155350 I get [karma] f90/bug% gfc -O3 where_2_db.f90 [karma] f90/bug% a.out 100 100 100 210 210 210 310 337 310 310 0 0 0 0 0 0 0 27 0 0 Abort [karma] f90/bug% gfc -m64 -O3 where_2_db.f90 [karma] f90/bug% a.out 100 100 100 210 210 210 310 310 337 337 0 0 0 0 0 0 0 0 27 27 [karma] f90/bug% while with r151300 I get: [karma] f90/bug% gfcp -O3 where_2_db.f90 [karma] f90/bug% a.out 100 100 100 210 210 210 310 310 337 337 0 0 0 0 0 0 0 0 27 27 [karma] f90/bug% gfcp -m64 -O3 where_2_db.f90 [karma] f90/bug% a.out 100 100 100 210 210 210 310 310 310 310 0 0 0 0 0 0 0 0 0 0 Abort [karma] f90/bug% So sum(reduce) gives the right result, but apparently it is not stored in the right place. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41082