wrong code with -fforce-addr
Hi, I have a rather nasty optimization issue with gfortran (as of yesterday). As I think it could be an optimization issue and not an gfortran frontend issue, I post it here, the fortran list was not able to help so far. I narrowed my problem to one single fortran function. If I compile this function with "gfortran -O2 -march=pentium4" the output is OK, using "gfortran -O2 -march=pentium4 -fforce-addr" produces wrong output. When reducing optimization level to "-O1", the issue vanishes for all tried flag combinations. If I comment out a particular non-functional line in this code, the issue goes away: if (always_true) then else this_line_commented_out_makes_it_working_again endif Further data points: - output of -fdump-tree-optimized is the same for both the working and the broken case (of the original function, not the line commenting test). - there are differences in assembler output though. - the code calls C functions. - I could reproduce this issue on an different, non-pentium4 machine using the same flags. - the flag -march=pentium4 is necessary to trigger the issue. I'm in a loss where to search for the real cause. Has anybody a hint how to proceed further? Should I post the code of this function here on the list (~300 LOC)? Thanks, Manfred
Re: wrong code with -fforce-addr
> > Hi, > > > > I have a rather nasty optimization issue with gfortran (as of > yesterday). As I think it could > > be an optimization issue and not an gfortran frontend issue, I post it > here, > > the fortran list was not able to help so far. > > > > I narrowed my problem to one single fortran function. If I compile this > function with > > "gfortran -O2 -march=pentium4" the output is OK, using > > "gfortran -O2 -march=pentium4 -fforce-addr" produces wrong output. > > > > When reducing optimization level to "-O1", the issue vanishes for all > tried flag combinations. > > If I comment out a particular non-functional line in this code, the > issue goes away: > > > > if (always_true) then > > > > else > >this_line_commented_out_makes_it_working_again > > > > endif > > > > Further data points: > > - output of -fdump-tree-optimized is the same for both the working and > the broken case (of the > > original function, not the line commenting test). > > - there are differences in assembler output though. > > - the code calls C functions. > > - I could reproduce this issue on an different, non-pentium4 machine > using the same flags. > > - the flag -march=pentium4 is necessary to trigger the issue. > > > > > > I'm in a loss where to search for the real cause. Has anybody a hint how > to proceed further? > > Should I post the code of this function here on the list (~300 LOC)? > > You should file a bugreport with bugzilla instead. > http://gcc.gnu.org/bugzilla > > Thanks, > Richard. It's http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33638 I first hoped to get help to narrow things a bit further, as my problem is really a bit strange, so I decided to first write an email. I simply assigned it now to the middle-end, but of course it could also be a gfortran issue. Thanks, Manfred -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
Re: wrong code with -fforce-addr
> On Wed, Oct 03, 2007 at 12:24:27PM +0200, Manfred Schwarb wrote: > > I'm in a loss where to search for the real cause. Has anybody a hint > > how to proceed further? > > Sounds like weird-but-somewhat-determinist behaviour you can get when > you do out-of-bounds access on the stack or this kind of problems. > Did you try valgrind or your os-of-choice equivalent on the code? > > OG. I retested with valgrind just now, there was actually one problem in an unrelated function ("Conditional jump or move depends on uninitialised value"). I fixed this now with proper initialization. After this correction the codes passes cleanly with valgrind and efence. But this did not help, I still do get wrong code with "-fforce-addr", the behaviour did not change at all. Thanks, Manfred -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser