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]
Other format: [Raw text]

Re: Empty loop elimination in 4.0 ?


Andrew Pinski wrote:

This:
int *f;
int i;
for (i=0;i<10;i++)
  f[i] = 0;

will be converted to:

memset (f, 0, i * sizeof(*f));
for (i=0;i<10;i++)
  ;

So we end up with an empty loop which then is removed by a later pass.
This is normal thing to do is have later passes remove junk.  The
pass which does this transformation has no business in acting as
loop DCE.

Yes, of course the warning has to be sensible enough to realize that this is not an empty loop from the point of view of the programmer. To me an empty loop is one which generates no code. Clearly the for loop that the programmer wrote here does generate code. So what you are pointing out is that this warning has to be clever enough to distinguish these cases -- sure, I agree!


-- Pinski



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