Refine memory dependence's notion of volatile semantics
authorPhilip Reames <listmail@philipreames.com>
Mon, 26 Jan 2015 18:54:27 +0000 (18:54 +0000)
committerPhilip Reames <listmail@philipreames.com>
Mon, 26 Jan 2015 18:54:27 +0000 (18:54 +0000)
commita7ad6a589c30bf316b2e0e9456f521de12d7a679
treebcca7a98a004d17ec779b0d3eb722e211ee1f742
parent805bc02c2b9500e6ae62dac5a075eb732ac83597
Refine memory dependence's notion of volatile semantics

According to my reading of the LangRef, volatiles are only ordered with respect to other volatiles. It is entirely legal and profitable to forward unrelated loads over the volatile load. This patch implements this for GVN by refining the transition rules MemoryDependenceAnalysis uses when encountering a volatile.

The added test cases show where the extra flexibility is profitable for local dependence optimizations. I have a related change (227110) which will extend this to non-local dependence (i.e. PRE), but that's essentially orthogonal to the semantic change in this patch. I have tested the two together and can confirm that PRE works over a volatile load with both changes.  I will be submitting a PRE w/volatiles test case seperately in the near future.

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

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