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: Re-run of loop pass


>>>>> "Michael" == Michael Hayes <m.hayes@elec.canterbury.ac.nz> writes:

    Michael> The first pass often eliminates the BIV associated with i
    Michael> and replaces the end of loop test i < 4 with a comparison
    Michael> of the incremented pointer associated with a + i with a +
    Michael> 4 (I think the elimination is only performed for targets
    Michael> with autoincrement addressing modes).  The second pass
    Michael> then finds that the initial value of BIV associated with
    Michael> a is not a constant and thus cannot determine the
    Michael> iteration count.

Or the second pass could learn to recongize some of these idioms.
For example, you seem to imply that if I write:

  int* i;
  int* j;
  for (i = j ; i < j + 4; ++j)
    ;

say, that loop can't figure out the number of iterations.  A little
algebra might be helpful here, since this is a reasonably common
idiom, especially in C++ using STL, and especially where `4' is
replaced by `k'.  So much so that if no-one else does this, I'll
probably get around to it.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com


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