Bug 25752 - g77 optimization problems
g77 optimization problems
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
high Severity high
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-02-02 15:41 EST by Ben Spencer
Modified: 2005-10-31 17:00 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-02-03 16:46:42 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ben Spencer 2001-02-02 15:41:24 EST
I am working with a large finite element program written in FORTRAN 77.  I
have repeatedly run into problems when I compile with g77 using -O or -O2. 
I am using gcc-g77-2.96-69.  The following is an example of a section of
code that has given me problems:  

     elas_range = u2f_plus - u2f_minus
c    write(*,*) elas_range  

      if (u(2) .gt. u2f_plus) then
         f(2) = tau_f * cr_area
         df_du(2,2) = 0.01 * cr_area * dtt
         u2bound(1) = u2f_plus - 0.01d0 * elas_range
         u2bound(2) = u2f_plus + 10.d0 * (u(2) - u2f_plus)
      elseif (u(2) .lt. u2f_minus) then
         f(2) = -tau_f * cr_area
         df_du(2,2) = 0.01 * cr_area * dtt
         u2bound(1) = u2f_minus - 10.d0 * (u2f_minus - u(2))
         u2bound(2) = u2f_minus + 0.01d0 * elas_range
      else
         df_du(2,2) = cr_area * dtt    
         f(2) = cr_area * tau_old + df_du(2,2)*(u(2)-u2_old)
         u2bound(1) = u2f_minus - 0.01d0 * elas_range
         u2bound(2) = u2f_plus + 0.01d0 * elas_range
      endif

As can be seen, the value of elas_range is needed inside the if /else
blocks.  Sometimes when the optimizations are turned on, it appears that it
is not computed before the if statement.  It ends up that the values for
u2bound are being computed as if elas_range were 0, which should not have
been the case.  If I uncomment the line where I print out elas_range before
the if statement, elas_range is properly computed.  Unfortunately, I cannot
reproduce this bug by putting the section of code into a small program.  It
only happens when compiled with the whole program, and even then, it only
happens sometimes.  

I have also had other strange problems appear when I compile with
optimizations that go away when I don't use the optimizations.  They happen
with both -O and -O2.  Such bugs are really hard to trace in such a big
program, and I have just resorted to not using any optimizations.  I have
no idea if they have anything to do with the problem I had with the section
of code above or not.
Comment 1 Jakub Jelinek 2001-02-02 15:50:52 EST
Without complete source I cannot track this down.
BTW: What other flags besides -O[12] are you passing to it? Any of
-march or -mcpu?
Comment 2 Ben Spencer 2001-02-02 16:01:14 EST
I was afraid of that.  I will try again to make a smaller program that can
replicate this.  I wasn't passing any other flags besides the -O.
Comment 3 Jakub Jelinek 2001-03-30 05:28:51 EST
If you manage to come up with a testcase, please reopen.

Note You need to log in before you can comment on or make changes to this bug.