https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84102
Bug ID: 84102 Summary: Fails to disambiguate Fortran (non-addressable?) global with array descriptor data Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- Created attachment 43269 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43269&action=edit reduced capacita This is split out from PR84037 with a reduced testcase. We fail to hoist the load of D1 from do i=1,Ng1 ! .. and multiply charge with x do j=1,Ng2 X(i,j) = X(i,j) * D1 * (i-(Ng1+1)/2.0_dp) end do end do which ultimatively causes a runtime alias check for vectorization to disambiguate D1 and X. Note X is allocate()d and properly gets a malloc DECL from PTA. But the function calls solve(X,Y0) and GCC believes this call may alter X.data (and other fields of the descriptor). X is real(kind=dp), intent(out), dimension(:,:) :: X inside solve so that might be very well possible. But of course X may not end up pointing to D1 for whatever details. My guess is that it's the usual 'you can't take the address of random stuff without annotating it in fortran'. If true this would deserve sth stronger than !TREE_ADDRESSABLE which we only trust for TU-local variables. -fwhole-program helps here to properly constrain D1.