This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: exceptions and threads---a survival tactic!


>  It could be that the compiler is able to optimize the
>  bound checking.  I mean, if you have a loop of the form
>
>  	for (i = 0; i < 100; i++) { /*...*/ }
>
>  and the array runds from 0 to 99, and i is not messed
>  with in the loop, the compiler can figure out that no
>  range check is actually needed.

Yep, however, peeking into the assembler output produced by DEC's  
Fortran compiler, it doesn't do that for loops like this:

      subroutine aap(x, y, n)
      integer n
      real x(n,n), y(n,n)
      integer i
      do i = 2, n
         do j = 2, n
            x(j, i) = (y(j-1,i) + y(j,i) + y(j,i-1))/3.
         enddo
      enddo
      end

which are somewhat more representative of the programs I was  
thinking of.  Apparently, the analysis necessary to move the  
index-to-bounds comparison out of the loop is too much for this  
compiler.

Cheers,
Toon.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]