This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [trunk] patch to clean up handling of pure and constant functions.
- From: Chris Lattner <clattner at apple dot com>
- To: Kenneth Zadeck <zadeck at naturalbridge dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Mark Mitchell <mark at codesourcery dot com>, Diego Novillo <dnovillo at google dot com>
- Date: Thu, 10 Apr 2008 09:33:25 -0700
- Subject: Re: [trunk] patch to clean up handling of pure and constant functions.
- References: <47FE2D21.7030307@naturalbridge.com>
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