NON_LVALUE_EXPR in GENERIC tree on i686

Ilmir Usmanov i.usmanov@samsung.com
Wed Aug 28 12:11:00 GMT 2013


Hello all.

I found strange behavior of 32-bit compiler. The compiler adds NON_LVALUE_EXPR to GENERIC tree when accesses to an element of massive.

To reproduce the issue I wrote the test program:

PROGRAM test
          IMPLICIT NONE
          INTEGER :: a(64), i

          DO i = 1,10
                  a(i) = i
          ENDDO
END

I compiled this simple FORTRAN program using gfortran from trunk. I built gcc twice, for 32-bit and 64-bit architectures. 32-bit gcc is

$ /opt/trunk-gcc-32/bin/gfortran -v
Using built-in specs.
COLLECT_GCC=/opt/trunk-gcc-32/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/trunk-gcc-32/libexec/gcc/i686-pc-linux-gnu/4.9.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --disable-bootstrap --with-gmp=/opt/gmp-32 --with-mpfr=/opt/mpfr-32 --with-mpc=/opt/mpc-32 --enable-languages=fortran,c,c++ --prefix=/opt/trunk-gcc-32/ --target=i686-pc-linux-gnu --build=i686-pc-linux-gnu
Thread model: posix
gcc version 4.9.0 20130827 (experimental) (GCC)

and the other is

$ /opt/trunk-gcc/bin/gfortran -v
Using built-in specs.
COLLECT_GCC=/opt/trunk-gcc/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/trunk-gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --disable-bootstrap --with-gmp=/opt/gmp --with-mpfr=/opt/mpfr --with-mpc=/opt/mpc --enable-languages=fortran,c,c++ --prefix=/opt/trunk-gcc/
Thread model: posix
gcc version 4.9.0 20130827 (experimental) (GCC)

When I compiled the program using 32-bit compiler or 64-bit compiler with -m32 key and dumped GENERIC tree, the dump had line

a[NON_LVALUE_EXPR <i> + -1] = i;

while dump from 64-bit compiler without any key had line

a[(integer(kind=8)) i + -1] = i;

Both of dumps are attached to the letter.
So, is this a bug? Should I open a PR?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.f95
Type: text/x-fortran
Size: 86 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130828/288bf8c4/attachment.bin>
-------------- next part --------------
test ()
{
  integer(kind=4) a[64];
  integer(kind=4) i;

  i = 1;
  if (i <= 10)
    {
      while (1)
        {
          {
            logical(kind=4) D.1825;

            a[NON_LVALUE_EXPR <i> + -1] = i;
            L.1:;
            D.1825 = i == 10;
            i = i + 1;
            if (D.1825) goto L.2;
          }
        }
    }
  L.2:;
}


main (integer(kind=4) argc, character(kind=1) * * argv)
{
  static integer(kind=4) options.0[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31};

  _gfortran_set_args (argc, argv);
  _gfortran_set_options (9, &options.0[0]);
  test ();
  return 0;
}


-------------- next part --------------
test ()
{
  integer(kind=4) a[64];
  integer(kind=4) i;

  i = 1;
  if (i <= 10)
    {
      while (1)
        {
          {
            logical(kind=4) D.1879;

            a[(integer(kind=8)) i + -1] = i;
            L.1:;
            D.1879 = i == 10;
            i = i + 1;
            if (D.1879) goto L.2;
          }
        }
    }
  L.2:;
}


main (integer(kind=4) argc, character(kind=1) * * argv)
{
  static integer(kind=4) options.0[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31};

  _gfortran_set_args (argc, argv);
  _gfortran_set_options (9, &options.0[0]);
  test ();
  return 0;
}




More information about the Fortran mailing list