https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123335
Bug ID: 123335
Summary: Missed vectorization for fortran deferred-shape array
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: liuhongt at gcc dot gnu.org
Target Milestone: ---
testcase:
MODULE DDD
REAL(8), DIMENSION(:,:,:), POINTER, CONTIGUOUS :: u
REAL(8), DIMENSION(:,:,:), POINTER, CONTIGUOUS :: v
REAL(8), DIMENSION(:), POINTER, CONTIGUOUS:: y
END MODULE
MODULE KKK
USE DDD, &
ONLY: u, &
v, &
y
IMPLICIT NONE
PRIVATE
PUBLIC square
INTERFACE square
MODULE PROCEDURE square_ij
END INTERFACE square
CONTAINS
SUBROUTINE square_ij(i, j, x1, x2)
implicit none
integer, intent(in) :: x1
integer, intent(in) :: x2
INTEGER :: i
INTEGER :: j
INTEGER :: k
DO k = x1, x2
y(k) = u(k,j, i) + v(k,j,i)
ENDDO
END SUBROUTINE square_ij
ENDMODULE KKK
link: https://godbolt.org/z/bvbn9h7oa
For deferred-shape array, compiler need to dynamically load element size so the
iv step is variable.
_15 = u.span;
And GCC can't do vectorization for that, but LLVM can vectorize the loop, I
guess it supports dynamic versioning for the iv step.
It's probably similar issue as PR101450 which also need dynamic versioning but
for overflow not the size of iv step.