Allow value forwarding past release fences in GVN
authorPhilip Reames <listmail@philipreames.com>
Fri, 25 Mar 2016 22:40:35 +0000 (22:40 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 25 Mar 2016 22:40:35 +0000 (22:40 +0000)
commitb5681138e41ea0c2712c6bf1b770f66391f45216
treefd7751f7ef543b21296c78666ce3a88cccce10b0
parent0e32c5283ae8307179da18ddeef112435bbcbf6b
Allow value forwarding past release fences in GVN

A release fence acts as a publication barrier for stores within the current thread to become visible to other threads which might observe the release fence. It does not require the current thread to observe stores performed on other threads. As a result, we can allow store-load and load-load forwarding across a release fence.

We choose to be much more conservative about stores.  In theory, nothing prevents us from shifting a store from after a release fence to before it, and then eliminating the preceeding (previously fenced) store.  Doing this without actually moving the second store is likely also legal, but we chose to be conservative at this time.

The LangRef indicates only atomic loads and stores are effected by fences. This patch chooses to be far more conservative then that.

This is the GVN companion to http://reviews.llvm.org/D11434 which applied the same logic in EarlyCSE and has been baking in tree for a while now.

Differential Revision: http://reviews.llvm.org/D11436

llvm-svn: 264472
llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/test/Transforms/DeadStoreElimination/fence.ll [new file with mode: 0644]
llvm/test/Transforms/GVN/fence.ll [new file with mode: 0644]