Sanjoy Das via llvm-dev
2016-Aug-25 23:29 UTC
[llvm-dev] invariant.load metadata semantics
Hi Daniel, Daniel Berlin wrote: > To be specific, does this imply "if we see a store, we can assume it is > of the same value the load already has"? > > IE if i have: > > func() > { > load a, invariant.load !1 > <use of a> > store a, 5 > } > > Can i assume that a in <use of a> has the value 5? Yes, that is what I had in mind. Moreover, in func() { int k = load a, invariant.load !1 print(k); store a, 5 } k can be optimized to 5, in a form of "time traveling store forwarding" :). The store (at least if non-atomic and non-volatile) is also trivially dead. But I'd rather not allow stores at all. -- Sanjoy
Michael Kuperstein via llvm-dev
2016-Aug-26 00:31 UTC
[llvm-dev] invariant.load metadata semantics
> > Yes, that is what I had in mind. Moreover, in > > func() > { > int k = load a, invariant.load !1 > print(k); > store a, 5 > } > > k can be optimized to 5, in a form of "time traveling store > forwarding" :). The store (at least if non-atomic and non-volatile) > is also trivially dead. > >Only if we know that print() returns, right? Otherwise, we have the usual trouble with things like: void print(int i) { if (k != 5) abort(); ... } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160825/51feeb96/attachment.html>
Sanjoy Das via llvm-dev
2016-Aug-26 00:36 UTC
[llvm-dev] invariant.load metadata semantics
Hi Michael, Michael Kuperstein wrote: > > > Yes, that is what I had in mind. Moreover, in > > func() > { > int k = load a, invariant.load !1 > print(k); > store a, 5 > } > > k can be optimized to 5, in a form of "time traveling store > forwarding" :). The store (at least if non-atomic and non-volatile) > is also trivially dead. > > > Only if we know that print() returns, right? Yes. -- Sanjoy