This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/57396] Wrong code with -fpredictive-commoning in Fortran double-loop


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57396

--- Comment #1 from Lorenz HÃdepohl <bugs at stellardeath dot org> ---
As the loop is quite confusing, i wrote a small python program to reproduce the
correct result:

> cat test.py
def foo(n):
    r = {}
    a = {}

    # initialize with some dummy values
    for i in range(-n, n + 1):
        for j in range(-n, n + 1):
            a[(i,j)] = j
            r[(i,j)] = j + 1

    # here be dragons
    for k in range(0, n + 1):
      dj = r[(k, k - 2)] * a[(k, k - 2)]
      r[(k,k)] = a[(k, k - 1)] * dj

    # print it out
    print "{0:12.8f}".format(r[(0,0)])

foo(5)
> python ./test.py
 -2.00000000
>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]