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: [tree-ssa] Dce & infinite loops



On Mar 18, 2004, at 08:12, Zdenek Dvorak wrote:
the simple conservative solution is to mark all back edges as neccesary.
You can do a bit better and use the results of simple loop analysis to
avoid doing this for back edges of loops for that you are sure that they terminate.
But you won't gain much by this in practice, since people usually do not
write useless loops. Also it is not clear whether people really want such
loop to be optimized out (they might write it in order to make the
program wait).

It is important to remove loops that are empty, but can be shown to terminate. Even though programmers may not write such code, other optimizations may make all code invariant, resulting in an empty loop.

True, long ago GCC did keep such loops, but that policy has been
explicitly reversed later on. If someone wants to keep a loop,
just make sure it has some external effect such as writing to
volatile memory.

I fail to see why you would need to have any special hacks to
prevent infinite loops from being optimized away. What is the
logic that causes this? There seems to be a more fundamental
problem if the optimizers determine that the function would
return 0. What if the loop was replaced with a call to a
function that is marked non-terminating?

-Geert


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