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 ?


In article <41E29055.5030507@adacore.com> you write:
>Andrew Pinski wrote:
>
>> Or even in C now a days with all the optimizations we could do like
>> converting some loops to memset which still keeps the loop because it is
>> ideal to have later passes delete the loop.
>
>A loop converted to memset is not an empty loop! Can you give
>some other example to show what you mean. to me if a loop ends
>up empty, it is always a case to warn the programmer about.

template<typename T>void 
dosomething(T a[], int n)
{
	for (int i = 0; i < n; i++)
		a[i].f();
}

Now, if you expand this for a typename where f is an inline function
that does nothing, this is an empty loop.

And there are somewhat less obvious cases. I don't know whether gcc
sees the template code before templates are expanded, and before inlines
are expanded. If I remember my C++ standard right, templates need to be
taken into account fairly early, as syntax may change because of them...


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