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]

Optimisation question/suggestion




Hi!

     egcs is a really great compiler, that performs lots of cse, and
other tricks...
but:  (of course... ;-)

there is some more  factorisation that would be interresting:

  int i,cond;

  cond = [something];
   for (i=0; i<1000; i++) {

     if (condition) {
       [piece of code 1]
     } else {
       [piece of code 2]
     }
    }

as condition doesn't change during the loop, it could be better compiled
if transformed in:

  int i,cond;
  if (condition) {
     for (i=0; i<1000; i++) {
       [piece of code 1]
     }
   } else {
          for (i=0; i<1000; i++) {
       [piece of code 2]
     }
   }



I don't know if that's easy to do, but that would be really great:
making 3 or 4 versions of the loops acording to condition inside...
I don't have for the moment enough time to dig into gcc and understand
how it works to implement this, so I let this a suggestion...


    Bye!




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