[LLVMdev] LICM/store-aliasing of global loads
eli.friedman at gmail.com
Tue Jul 22 10:48:59 CDT 2008
On Mon, Jul 21, 2008 at 3:51 PM, Stefanus Du Toit <sdt at rapidmind.com> wrote:
> The latter should technically allow the same freedom to these
> optimizations, but doesn't currently seem to. Furthermore, the latter
> should give the RA enough information to rematerialize these loads
> instead of spilling them if necessary.
Yes... the issue is roughly that alias analysis works between
addresses, not instructions, so it can't tell that a store can't alias
a load from a constant global.
> If I apply the patch found further down, LICM moves the loads out (as
> expected), but of course this is a fairly specific fix.
Yes... the attached patch looks correct.
> What's the right way to handle this? Should Basic AA handle this case?
> Will the RA be aware that it can remat these loads or do I need to do
> something else to allow it to know this? Will the scheduler be aware
> that it can reorder them?
The best way to go about this is probably case-by-case, at least at
the moment... the const-ness of a global provides information that
isn't otherwise possible to express. Remat can probably be extended
to be aware of const-ness when remat-ing loads.
This will probably be fixed properly once LLVM gets type-based alias
More information about the LLVMdev