[LICM] hoist fences out of loops w/o memory operations
authorPhilip Reames <listmail@philipreames.com>
Thu, 9 Aug 2018 20:18:42 +0000 (20:18 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 9 Aug 2018 20:18:42 +0000 (20:18 +0000)
commitca256d93fb352746a9f1912e1838804a0e1efc4f
tree8da7883319415a77cda4e04b97e468b85be3e87c
parented4f51755ec7d72a290e6055e5eddc50a93360e3
[LICM] hoist fences out of loops w/o memory operations

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.

Differential Revision: https://reviews.llvm.org/D50489

llvm-svn: 339378
llvm/include/llvm/Analysis/AliasSetTracker.h
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/test/Transforms/LICM/fence.ll