This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/57396] Wrong code with -fpredictive-commoning in Fortran double-loop
- From: "bugs at stellardeath dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 May 2013 10:17:55 +0000
- Subject: [Bug tree-optimization/57396] Wrong code with -fpredictive-commoning in Fortran double-loop
- Auto-submitted: auto-generated
- References: <bug-57396-4 at http dot gcc dot gnu dot org/bugzilla/>
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
>