[llvm-dev] invariant.load metadata semantics

Philip Reames via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 26 11:41:09 PDT 2016



On 08/25/2016 05:36 PM, Sanjoy Das via llvm-dev wrote:
> 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.
Agreed.  Another way to view this is that we transform your example to:
func() {
        int k = load a, invariant.load !1
        print(k);
        assume(*a == 5)
  }
And then optimize from there.  As pointed out, the assumption only kicks 
in when you can prove that it will actually execute.




More information about the llvm-dev mailing list