Bug 25752 - g77 optimization problems
Summary: g77 optimization problems
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.0
Hardware: i386 Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2001-02-02 20:41 UTC by Ben Spencer
Modified: 2005-10-31 22:00 UTC (History)
0 users

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

Attachments (Terms of Use)

Description Ben Spencer 2001-02-02 20:41:24 UTC
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
         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

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 20:50:52 UTC
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 21:01:14 UTC
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 10:28:51 UTC
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.