19991025/g77 686 unrolling bug at -O2

Timothy C Prince tprince@myrealbox.com
Thu Oct 28 09:29:00 GMT 1999


The following loop is generating erroneous code when 
compiled in full context with -O2 -funroll-loops 
-march=pentiumpro.  Any of 
the following changes will produce correct code:
-Os
no-unroll-loops
-fno-automatic

In case it is relevant, the loop contains sequential 
dependencies over both indices, and has never been seen to 
optimize for 686 except by unrolling over both indices. The 
magnitude of the error varies with what should be 
irrelevant changes such as insertion of parentheses.  
I have been struggling to find a similar case of manageable 
size; the full case is to be found at 
ftp://members.aol.com/n8tm/lloops.shar.gz
in the file lfk537g.f, in the KERNEL 23 section.

If someone is working on a similar problem, great; if not, 
I'm looking for suggestions on how to make a simple test 
case.
      implicit double precision (f,z)
....
	    do j= 2,6
	      do k= 2,n		  
      za(k,j)=za(k,j)+fw*(za(k,j+1)*zr(k,j)-za(k,j)+
     &za(k,j-1)*zb(k,j)+za(k+1,j)*zu(k,j)+
     &zz(k,j)+zv(k,j)*za(k-1,j))     
     		end do
	    end do



More information about the Gcc-bugs mailing list