<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Right now, with the alias analysis change marking invariant.start as readonly, we do not  value forward to invariant.end (which is still readwrite). 
<div class=""><br class="">
</div>
<div class="">Also, the only use of invariant.start is the corresponding invariant.end, so I think we would be okay as long as we do not change invariant.end to be readonly. Added the test case to GVN.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">define i8 @forward_store1() {</div>
<div class="">  %a = alloca i8</div>
<div class="">  store i8 0, i8* %a</div>
<div class="">  %foo = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a) </div>
<div class="">  %r = load i8, i8* %a</div>
<div class="">  %bar = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a) </div>
<div class="">  call void @llvm.invariant.end.p0i8({}* %bar, i64 1, i8* %a) <— this remains as invariant.end(%bar..)</div>
<div class="">  ret i8 %r</div>
<div class="">}</div>
</div>
<div class=""><br class="">
</div>
<div class="">However, the value forwarding will happen when invariant.end is marked readonly as well. </div>
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="">
<div class="">foo = invariant.start(a)</div>
<div class=""><stuff><br class="">
bar = invariant.start(a)</div>
<div class="">invariant.end (foo) <— was invariant.end(bar) initially</div>
</div>
</div>
</blockquote>
<br class="">
</div>
<div class="">Daniel, </div>
<div class=""><br class="">
</div>
<div class="">Even with the value forwarding , I think the “invariant set of statements” are not modified. We are not increasing/decreasing the number of “invariant uses" of %a, even though the range of statements within invariant.start and end for foo and
 bar has changed. I think this is true for any other case where the value forwarding modifies invariant.end (since there would be some invariant.start which is still alive, and maintaining the invariance for uses of %a)</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Anna</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Aug 6, 2016, at 12:30 PM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org" class="">dberlin@dberlin.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">So, this value forwards in a case i hadn't thought about.
<div class=""><br class="">
</div>
<div class="">foo = lifetime.start(p)</div>
<div class=""><stuff><br class="">
bar = lifetime.start(p)</div>
<div class="">lifetime.end (bar)</div>
<div class=""><br class="">
</div>
<div class="">will become</div>
<div class="">
<div class="">foo = lifetime.start(p)</div>
<div class=""><stuff><br class="">
bar = lifetime.start(p)</div>
<div class="">lifetime.end (foo)</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I'm not sure the above is even valid, but i found it in Real Live Code(TM).</div>
<div class=""><br class="">
</div>
<div class="">Thoughts?<br class="">
<br class="">
</div>
<div class=""><br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Fri, Aug 5, 2016 at 10:15 PM, Anna Thomas <span dir="ltr" class="">
<<a href="mailto:anna@azul.com" target="_blank" class="">anna@azul.com</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
anna added a comment.<br class="">
<br class="">
Changing the code to teach Alias analysis (instead of MDA) about the readonly nature of MDA. All the tests are still valid (and checks remain the same).<br class="">
getModRefInfo is used by MDA, so the implications on the various passes (GVN, Memcpyopt and DSE) should be the same, it’s just that the code change will be within the same code region where other special cases for llvm.assume and guard intrinsics exist.<br class="">
<br class="">
Making the change in alias analysis rather than MDA stemmed from the discussion in llvm-commits mailing list with dberlin and sanjoy.<br class="">
<br class="">
<br class="">
<a href="https://reviews.llvm.org/D23214" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D23214</a><br class="">
<br class="">
<br class="">
<br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>