This is an archive of the discontinued LLVM Phabricator instance.

[LICM] hoist fences out of loops w/o memory operations
ClosedPublic

Authored by reames on Aug 8 2018, 9:30 PM.

Details

Summary

The motivating case is an otherwise dead loop with a fence in it. At the moment, this goes all the way through the optimizer and we end up emitting an entirely pointless loop on x86. This case may seem a bit contrived, but we've seen it in real code as the result of otherwise reasonable lowering strategies combined w/thread local memory optimizations (such as escape analysis).

To handle this simple case, we can teach LICM to hoist must execute fences when there is no other memory operation within the loop.

Diff Detail

Event Timeline

reames created this revision.Aug 8 2018, 9:30 PM
skatkov accepted this revision.Aug 8 2018, 9:57 PM
skatkov added inline comments.
include/llvm/Analysis/AliasSetTracker.h
228

Please document that method may return nullptr if it cannot determine the unique instruction by any reason.

lib/Transforms/Scalar/LICM.cpp
696

Don't you want to assert that if Begin->getUniqueInstruction() != then it should be FI?

This revision is now accepted and ready to land.Aug 8 2018, 9:57 PM
This revision was automatically updated to reflect the committed changes.