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

            Bug ID: 127303
           Summary: Bounds checking inhibits vectorization in DO loop
                    although checks could removed
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org
  Target Milestone: ---

On x86_64.

subroutine foo(a,b,c,n)
  integer, intent(in) :: n
  real, dimension(n), intent(in) :: a,b
  real, dimension(n), intent(out) :: c
  integer :: i
  do i=1,n
     c(i) = a(i) + b(i)
  end do
end subroutine foo

the inner loop is, with a recent trunk and -O3 -fcheck=bounds,

.L4:
        cmpq    %rcx, %rdx
        je      .L10
        movss   -4(%rdi,%rdx,4), %xmm0
        addss   -4(%rsi,%rdx,4), %xmm0
        movss   %xmm0, -4(%r8,%rdx,4)
        addq    $1, %rdx
        cmpl    %edx, %eax
        jge     .L4

(.L10 branches to runtime error). The cmpq instruction is a check against
INT_MAX.

This does not happen for KIND=8 i and n, by the way.

Reply via email to