[llvm-dev] invariant.load metadata semantics

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 25 16:29:07 PDT 2016


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


More information about the llvm-dev mailing list