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: Fortran: The Road Ahead.


  > > III. New loop optimisations.
  > >
  > >     1. Moving invariant conditionals out of loops.

>  Compiler folks often refer to this as unswitching.  Note
>  that the conditional must be at the top of the loop to
>  perform this kind of optimization.

(Sigh).  OK, guys, I probably simplified too much.  The  
optimisation I really had in mind ran something like this:

   Transform:

      do i = 1, n
         <body1>
         if (lcond) then
            <body2>
         else
            <body3>
         endif
         <body4>
      enddo

   into (variant I):

      if (lcond) then
         do i = 1, n
            <body1>
            <body2>
            <body4>
         enddo
      else
         do i = 1, n
            <body1>
            <body3>
            <body4>
         enddo
      endif

    or (variant II):

      do i = 1, n
         <body1>
      enddo
      if (lcond) then
         do i = 1, n
            <body2>
         enddo
      else
         do i = 1, n
            <body3>
         enddo
      endif
      do i = 1, n
         <body4>
      enddo

It would be especially interesting to come up with a heuristic to  
choose between variant I and variant II, *given the other  
transformations I mentioned* :-)

Cheers,
Toon.


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