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

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
The fortran fail can be reduced to the following with -O1 -fipa-pta, not
sure what goes wrong.  It looks like part of the

  a (idx (10:6:-2)) = b (idx (10:6:-2))

stores are wrongly elided.

! PR 19239.  Check for various kinds of vector subscript.  In this test,
! all vector subscripts are indexing single-dimensional arrays.
! { dg-do run }
program main
  implicit none
  integer, parameter :: n = 10
  integer :: i, j, calls
  integer, dimension (n) :: a, b, idx, id

  idx = (/ 3, 1, 5, 2, 4, 10, 8, 7, 6, 9 /)
  id = (/ (i, i = 1, n) /)
  b = (/ (i * 100, i = 1, n) /)

  !------------------------------------------------------------------
  ! Tests for a simple variable subscript
  !------------------------------------------------------------------

  a (idx) = b
  call test (idx, id)

  a = b (idx)
  call test (id, idx)

  a (idx (1:7:3)) = b (idx (10:6:-2))
  call test (idx (1:7:3), idx (10:6:-2))

  a (idx (10:6:-2)) = b (idx (10:6:-2))
  call test (idx (10:6:-2), idx (10:6:-2))

contains
  subroutine test (lhs, rhs)
    integer, dimension (:) :: lhs, rhs
    integer :: i

    if (size (lhs, 1) .ne. size (rhs, 1)) STOP 11
    do i = 1, size (lhs, 1)
      if (a (lhs (i)) .ne. b (rhs (i))) STOP 12
    end do
    a = 0
  end subroutine test
end program main

Reply via email to