[Bug tree-optimization/123335] New: Missed vectorization for fortran deferred-shape array
liuhongt at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Dec 30 06:33:08 GMT 2025
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.
More information about the Gcc-bugs
mailing list