[llvm-commits] [PATCH] Tail recursion elimination and memory loads.
Frits van Bommel
fvbommel at wxs.nl
Tue Jun 16 13:49:41 PDT 2009
When tail recursion elimination (opt -tailcallelim) sees other instructions
between the recursive call and the return instruction, it tries to figure out if
it's safe to move them above the call (putting the call in tail position).
However, it refuses to do that for load instructions after the call.
The attached patch checks for some conditions in which it is safe to do this for
loads as well.
There are two basic cases:
1) The call has no side-effects, in which case it's always safe since the load
would happen anyway and it shouldn't matter if it's done a bit sooner.
2) The load is non-volatile, the call does not write to memory, and the
pointer isSafeToLoadUnconditionally() at that point in the code. In this case,
the load has no side-effects (and won't trap) and the memory it loads from won't
contain different data after the call, making it safe to raise the load above
the call.
If the load and call in question satisfy either of these conditions tail
recursion elimination will be allowed (or at least, it won't be blocked by that
load).
See also: http://llvm.org/PR4323
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tailcallelim-reorder-load.patch
Type: text/x-patch
Size: 7871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090616/f84d7c10/attachment.bin>
More information about the llvm-commits
mailing list