fortran/893: Preliminary loop exit compiled wrongly

Alfredo Ferrari list@pceet030.cern.ch
Wed Nov 29 13:33:00 GMT 2000


On Wed, 29 Nov 2000, Toon Moene wrote:

> List subscription (i.e., Alfredo Ferrari) wrote:
>
> > that patch seems to fix that bug and similar ones I found and reported.
> > The patch was issued after I made a report to Bugzilla (the RH bug tracking
> > system). They reacted at the speed of light.... many thanks to Jakub
> > Jelinek from RedHat.
>
> Thanks Jakub !   I guess you created the C test suite file because you
> weren't sure the Fortran one triggered the same bug ?
>
> > For Toon: indeed the 7+ miscompiled routines I had seem to be all ok after
> > this patch (the bug was indeed very "popular").
>
> Well, it *could* turn up in any loop with a goto going outside the loop
> to a label not immediately following the loop end.  If you're code does
> that a lot, there are a lot of opportunities for the bug to rear its
> ugly head ...
>
Yes, this kind of loops are typical in MonteCarlo codes when you make
random selections of variables: you loop on a cumulative distribution,
you compare with a random number and then you jump out (of course with
infinite variations depending on possible rejection techniques etc etc).
>
> Note how:
>
> 1. This bug must have been there for more than a year, as the MEM
>    hoisting code is more than a year old.
>
It could well be. I sticked up to now with egcs-1.1.2 and I moved
only when I upgraded on one of my machine (the guinea pig one at home)
to RH7.

> 2. The bug amazingly only triggered on the Intel architecture, while it
>    was in a thoroughly general piece of optimization code, independent
>    of the target architecture.
>
That's really funny!
> > I am still in the process
> > to check carefully whether there are other problems floating around or not
> > for what concerns our codes, I'll let you know.
>
> Thanks, I'd really appreciate that !
>
I'll let you know. It will take at least one week to run a reasonable
large set of test cases, compare results with other architecture etc.
I am happy to (get) help!
> > A naive question: is
> > there any reason why the present g77 is significantly slower than the
> > one in egcs-1.1.2 (20-30% slower on all the tests I made up to now, and
> > now the results are consistent so the comparison should be sound)?
>
> I know that in the past several bugs like the one fixed by Jakub have
> been repaired.  The loop optimization code is very old (perhaps around
> 13 years old) and lots of optimizations are invalid if not all of the
> code in the loop body is executed every turn (like in this "early-exit"
> example).  It would not be unthinkable that egcs-1.1.2 still contains
> several optimizations that are unsafe in general, but just happen to
> work on your code.  Note that I'm guessing here - without thorough
> examination of your code and the generated intermediate representation
> in the compiler for both egcs-1.1.2 and the current snapshots nothing
> can be concluded with certainty.
>
> Hope this helps,
>
>
Ok, of course it is a bit disappointing to run slower than in the past,
but it is worth if it means more robustness. I don't think you are
interested in getting the intermediate representation of a 400,000 line
code... MonteCarlo codes are always difficult to optimize properly since
almost no loop has a definite length. What is amazing is how the Digital
Unix fortran compiler is good in doing this. Our code runs twice as fast
on an Alpha chip @ 500 MHz (native compiler) than on a Pentium III @ 733
MHz with optimization on. Without optimization I get roughly the ratio of
the clocks

                      Thanks a lot
                    Alfredo Ferrari
-- 

+----------------------------------------------------------------------------+
|  Alfredo Ferrari                         ||  Tel.: +41.22.767.6119         |
|  C.E.R.N.                                ||  Fax.: +41.22.767.7555         |
|  European Laboratory for Particle Physics||                                |
|  SL Division / EET Project               ||  e-mail:                       |
|  1211 Geneva 23                          ||     Alfredo.Ferrari@cern.ch    |
|  Switzerland                             ||     Alfredo.Ferrari@mi.infn.it |
+----------------------------------------------------------------------------+



More information about the Gcc-bugs mailing list