https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115710
Bug ID: 115710 Summary: fortran complex abs does not vectorise 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: --- subroutine foo(a,b,n) complex(kind(1d0))::a(*) real(kind(1d0))::b(*) integer::i,n do i=1,n b(i)=abs(a(i))**2 end do end subroutine foo fails to vectorise with "gfortran-14 -mavx2 -mfma -Ofast". I am very impressed that the **2 simply removes the sqrt, so the above code is simpler than the code without **2 (which also doesn't vectorise, and should). I am also impressed that b(i)=a(i)*conjg(a(i)) and b(i)=real(a(i))*real(a(i))+aimag(a(i))*aimag(a(i)) produce identical, vectorised, assembler. But the abs example ought to be the same too.