This is the mail archive of the gcc-patches@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: Tweak to gengtype



On 20/01/2005, at 3:06 PM, Steven Bosscher wrote:


On Friday 21 January 2005 00:05, Geoffrey Keating wrote:
GCC should really be able to remove a trivial empty loop like this one.
It's easy to prove that it (a) really is empty and (b) is guaranteed
to terminate. (The second condition is a bit harder, but all the logic
should be there.) Do you know why it's not being removed?

A design choice. GCC does not remove empty loops because people don't want it to do so.

I thought we changed that in the late 1990s.


In fact, the current documentation says:

Be aware of this when performing timing tests, for instance the
following loop can be completely removed, provided
@code{some_expression} can provably not change any global state.

@smallexample
@{
   int sum = 0;
   int ix;

   for (ix = 0; ix != 10000; ix++)
      sum += some_expression;
@}
@end smallexample

Is the rule that only syntactically empty loops are not removed? If so, maybe we should put '(void) 0;' at the top of each loop in gengtype.


Attachment: smime.p7s
Description: S/MIME cryptographic signature


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