[Bug middle-end/103101] New: testsuite/gfortran.dg/vector_subscript_1.f90 fails with -fipa-pta (apparently due to dom bug)

hubicka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 5 16:53:31 GMT 2021


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

            Bug ID: 103101
           Summary: testsuite/gfortran.dg/vector_subscript_1.f90 fails
                    with -fipa-pta (apparently due to dom bug)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hubicka at gcc dot gnu.org
  Target Milestone: ---

Building testcase with:
/aux/hubicka/trunk/build5/gcc/testsuite/gfortran2/../../gfortran
-B/aux/hubicka/trunk/build2/gcc/testsuite/gfortran2/../../
-B/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libgfortran/
/aux/hubicka/trunk/gcc/testsuite/gfortran.dg/vector_subscript_1.f90
-fdiagnostics-plain-output -fdiagnostics-plain-output -O1 -pedantic-errors
-B/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libgfortran/.libs
-L/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libgfortran/.libs
-L/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libgfortran/.libs
-L/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libatomic/.libs
-B/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libquadmath/.libs
-L/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libquadmath/.libs
-L/aux/hubicka/trunk/build5/x86_64-pc-linux-gnu/./libquadmath/.-tree-all-details
 -fipa-pta

leads to abort STOP 12

I have reduced the testcase somewhat as:

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

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

  !------------------------------------------------------------------
  ! Tests for constant ranges with non-default stride
  !------------------------------------------------------------------

  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

This fails when built with -O1 -fipa-pta and works with -O1 or -O1 -fipa-pta
-fno-tree-dominator-opts

In dom2 we replace:
  <bb 6> [local count: 292809384]:
  # S.22_125 = PHI <S.22_63(6), 0(5)>
  _7 = S.22_125 * 3;
  _60 = MEM <integer(kind=4)[0:]> [(integer(kind=4)[0:] *)&idx][_7];
  _8 = S.22_125 * -2;
  _61 = MEM <integer(kind=4)[0:]> [(integer(kind=4)[0:] *)&idx + 36B][_8];
  _9 = (integer(kind=8)) _61;
  _10 = _9 + -1;
  _11 = (integer(kind=8)) _60;
  _12 = _11 + -1;
  _13 = FRAME.37.b[_10];
  FRAME.37.a[_12] = _13;
  S.22_63 = S.22_125 + 1;
  if (S.22_63 > 2)
    goto <bb 7>; [25.00%]
  else
    goto <bb 6>; [75.00%]

  <bb 7> [local count: 97603128]:
  parm.23.span = 4;
  MEM <c_char[8]> [(struct dtype_type *)&parm.23 + 24B] = {};
  parm.23.dtype.elem_len = 4;
  parm.23.dtype.rank = 1;
  parm.23.dtype.type = 1;
  parm.23.dim[0].lbound = 1;
  parm.23.dim[0].ubound = 3;
  parm.23.dim[0].stride = 3;
  parm.23.data = &idx[0];
  parm.23.offset = -3;
  parm.24.span = 4;
  MEM <c_char[8]> [(struct dtype_type *)&parm.24 + 24B] = {};
  parm.24.dtype.elem_len = 4;
  parm.24.dtype.rank = 1;
  parm.24.dtype.type = 1;
  parm.24.dim[0].lbound = 1;
  parm.24.dim[0].ubound = 3;
  parm.24.dim[0].stride = -2;
  parm.24.data = &idx[9];
  parm.24.offset = 2;
  test (&parm.23, &parm.24); [static-chain: &FRAME.37]
  parm.23 ={v} {CLOBBER};
  parm.24 ={v} {CLOBBER};

  <bb 8> [local count: 292809384]:
  # S.27_126 = PHI <S.27_89(8), 0(7)>
  _14 = S.27_126 * -2;
  _87 = MEM <integer(kind=4)[0:]> [(integer(kind=4)[0:] *)&idx + 36B][_14];
        ^^^^ this by:
  _87 = _61;

_61 is initialized in loop and does not seem to be loop invariant, so I do not
see why dom thinks it is equivalent to _87 and the details dump does not seem
helping.


More information about the Gcc-bugs mailing list