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: [trunk] patch to clean up handling of pure and constant functions.



On Apr 10, 2008, at 8:07 AM, Kenneth Zadeck wrote:


pr33826 dealt with pure and constant functions that might infinite loop. Mark, wearing his language committee hat, has decreed that such functions cannot be pure or const because it is not legal to change an infinite looping into a terminating program. I do not disagree with this interpretation but it is more conservative than the compiler needs.

In fact, it is only necessary not to dead code eliminate potientially looping pure or const function, it is perfectly fine to perform code motion on such functions.

Is this true in general? What about something like:



int x; for (...) { printf("in loop"); x = some_const_function_that_might_loop(); }

It is safe to transform this to:

int x = some_const_function_that_might_loop();
for (...)
  printf("in loop");

permitting code motion across other side-effect-free statements seems fine.

-Chris


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