F77 compiler on R10000 SGI Indigo2: buggy?



 Dear Netters,
 Below is a short FORTRAN code that I wrote solely for the purpose of
 testing the system subroutine DTIME in SGI IRIX 6.2. This subroutine
 returns the elapsed CPU time since the last call to DTIME. I have
 compiled it on SGI Indigo2 with R10000 processor using MIPSpro F77
 compiler. I have used five different option sets listed below:
 1) f77 silly.f -o silly        (this produces 32-bit mips2 code by default)
 2) f77 -O2 silly.f -o silly
 3) f77 -64 silly.f -o silly    (this produces 64-bit mips4 code)
 4) f77 -64 -O2 silly.f -o silly
 5) f77 -64 -O3 silly.f -o silly
 The unusual results I have obtained are shown in table below. Apart
 from the fact that the 64-bit executables produce slightly different
 result for x than their 32-bit counterparts, the CPU times in column
 4) are larger by a factor of TEN in comparison to other columns!
 Normally, I would expect them to be in between 3) and 5). This abnormal
 result is reproducible for every SGI R10000 machine that we have here.
 It seems that options -64 and -O2 don't get along very well. Is there
 something I don't understand about MIPSpro F77 optimization options? Am I
 missing something? Or is there a bug in the compiler?
 Please, recompile this code on your R10000 (if you have it :-) to confirm
 or deny this observation.
       program silly
       implicit double precision (a-h,o-z)
       real tarray(2)
       x=0.d0
       jmax=100
       call dtime(tarray)
       do imax=8000,10000,100
        do i=1,imax
         do j=1,jmax
          x=x+sqrt(float(i))*sin(float(j))
          y=acos(x/(i*abs(x)))
         enddo
        enddo
        call dtime(tarray)
        print *,imax,tarray(1)+tarray(2)
       enddo
       print *,x,y
       stop
       end
 Results:
 ------------------------------------------------------------------------
        | CPU times (s) reported by DTIME for different compiler options|
   imax -----------------------------------------------------------------
        |     1)    |      2)    |      3)    |      4)    |      5)    |
 ------------------------------------------------------------------------
   8000 | 0.8353710 |  0.6551640 |  0.6200770 |   6.131035 |  0.1884840 |
   8100 | 0.8722960 |  0.6899580 |  0.6547980 |   6.208158 |  0.1924730 |
   8200 | 0.8814020 |  0.6967919 |  0.6354470 |   6.280854 |  0.1928640 |
   8300 | 0.8918310 |  0.6798510 |  0.6682850 |   6.354552 |  0.1953330 |
   8400 | 0.9021270 |  0.7131230 |  0.6759790 |   6.454478 |  0.1976650 |
   8500 | 0.9128000 |  0.7212590 |  0.6588350 |   6.503715 |  0.2249840 |
   8600 | 0.9232100 |  0.7044880 |  0.6914790 |   6.604474 |  0.2023520 |
   8700 | 0.9336550 |  0.7377620 |  0.6991270 |   6.682483 |  0.2047420 |
   8800 | 0.9442470 |  0.7459780 |  0.7070640 |   6.732563 |  0.2070200 |
   8900 | 0.9545040 |  0.7541710 |  0.6897570 |   6.828230 |  0.2343980 |
   9000 | 0.9649110 |  0.7372350 |  0.7226390 |   6.902500 |  0.2117620 |
   9100 | 0.9503450 |  0.7706130 |  0.7303350 |   6.977732 |  0.2140380 |
   9200 | 0.9860920 |  0.7787640 |  0.7130180 |   7.052145 |  0.2164480 |
   9300 | 0.9962510 |  0.7868320 |  0.7457520 |   7.127767 |  0.2188510 |
   9400 |  1.006923 |  0.7699320 |  0.7534280 |   7.226908 |  0.2460940 |
   9500 |  1.017477 |  0.8030970 |  0.7614270 |   7.281057 |  0.2234870 |
   9600 |  1.052756 |  0.8112460 |  0.7440030 |   7.351462 |  0.2258430 |
   9700 |  1.038267 |  0.8196840 |  0.7766720 |   7.452884 |  0.2281600 |
   9800 |  1.048346 |  0.8278640 |  0.7845440 |   7.500894 |  0.2555520 |
   9900 |  1.059044 |  0.8359420 |  0.7923810 |   7.600510 |  0.2328600 |
  10000 |  1.069380 |  0.8191160 |  0.7999970 |   7.650619 |  0.2352500 |
 ------------------------------------------------------------------------
    x   |   -1522838.034014487   |          -1522834.807409876          |
 ------------------------------------------------------------------------
    y   |    1.570896326795063   |           1.570896326795063          |
 ------------------------------------------------------------------------
 Best regards,
 Robert Fraczkiewicz
 University of Texas Meedical Branch
 Galveston, TX 77555