https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115563

            Bug ID: 115563
           Summary: Unnecessary brackets prevent fortran vectorisation
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mjr19 at cam dot ac.uk
  Target Milestone: ---

The code

subroutine foo(a,n)

  complex (kind(1d0)) :: a(*)
  integer :: i,n

!$OMP SIMD
  do i=1,n
     a(i)=(a(i)+(6d0,1d0))
  enddo

end subroutine foo

compiled with

$ gfortran-14 -S -O3 -ffast-math -fopenmp-simd  -mavx2 t3.f90

does not vectorise.

$ grep -c ymm t3.s 
0

If the extra brackets are removed, so that the loop line reads

     a(i)=a(i)+(6d0,1d0)

then it does.

$ grep -c ymm t3.s 
3

It seems surprising that the code produced should differ depending on whether
the brackets are present, as I do not believe that they alter the meaning of
the code in any way. One can construct many similar examples, e.g. using a
complex variable in the place of the (6d0,1d0), or using a real constant, etc.

Reply via email to