<div dir="ltr"><div>It's EarlyCSE that is doing the damage in this case:</div><div><br></div><div>; Function Attrs: norecurse nounwind readonly uwtable<br>define dso_local i32 @foo(i32* nocapture readonly %0, i32* nocapture readonly %1) local_unnamed_addr #0 {<br> %3 = load i32, i32* %0, align 4, !tbaa !3<br> %4 = load i32, i32* %1, align 4, !tbaa !3<br> %5 = add nsw i32 %4, %3<br> %6 = load i32, i32* %0, align 4, !tbaa !3, !alias.scope !7<br> %7 = load i32, i32* %0, align 4, !tbaa !3, !noalias !7<br> %8 = add nsw i32 %7, %6<br> %9 = load i32, i32* %1, align 4, !tbaa !3, !noalias !7<br> %10 = add nsw i32 %8, %9<br> %11 = add nsw i32 %5, %10<br> ret i32 %11<br>}<br>*** IR Dump After Early CSE w/ MemorySSA ***<br>; Function Attrs: norecurse nounwind readonly uwtable<br>define dso_local i32 @foo(i32* nocapture readonly %0, i32* nocapture readonly %1) local_unnamed_addr #0 {<br> %3 = load i32, i32* %0, align 4, !tbaa !3<br> %4 = load i32, i32* %1, align 4, !tbaa !3<br> %5 = add nsw i32 %4, %3<br> %6 = add nsw i32 %3, %3<br> %7 = add nsw i32 %6, %4<br> %8 = add nsw i32 %5, %7<br> ret i32 %8<br>}</div><div><br></div><div>The problem is that EarlyCSE is not aware of the aliasing metadata at all - it just sees two loads that look the same and chooses one to die.</div><div><br></div><div>Cheers,</div><div>-Neil.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 22, 2020 at 2:14 PM Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hi, Neil,</p>
<p>When you say CSE, do you mean EarlyCSE or GVN?</p>
<p>Is the metadata being combined using MDNode::intersect or AAMDNodes::intersect?</p>
<p> -Hal<br>
</p>
<div>On 1/22/20 7:02 AM, Neil Henning via llvm-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>So I've been narrowing down a very fun issue in our Burst compiler stack with respect to noalias support, and I've managed to basically boil this down to the following failure (see
<a href="https://godbolt.org/z/-mdjPV" target="_blank">https://godbolt.org/z/-mdjPV</a>):</div>
<div><br>
</div>
<div>
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)">
<div><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> called(</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)">* __restrict__ a,
</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)">* b,
</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)">* c) {</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> *a + *b + *c;</span></div>
<div><span style="color:rgb(0,0,0)">}</span></div>
<br>
<div><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> foo(</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> * x,
</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> * y) {</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> *x + *y + called(x, x, y);</span></div>
<div><span style="color:rgb(0,0,0)">}</span></div>
<br>
<div><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> bar(</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> * x,
</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> * y) {</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> called(x, x, y) + *x + *y;</span></div>
<div><span style="color:rgb(0,0,0)">}</span></div>
</div>
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)"><br>
</div>
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)">Which becomes:</div>
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)"><br>
</div>
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)">
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)">
<div><span style="color:rgb(0,0,255)">define</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">dso_local</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">@called</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">noalias</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">2</span><span style="color:rgb(0,0,0)">)
</span><span style="color:rgb(0,128,128)">local_unnamed_addr</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">#0</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">7</span><span style="color:rgb(0,0,0)"> {</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%4</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">19</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%5</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">24</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%6</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">add</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">nsw</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">5</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">25</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%7</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">2</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">26</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%8</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">add</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">nsw</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">6</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">7</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">27</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,255)">ret</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">8</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">28</span></div>
<div><span style="color:rgb(0,0,0)">}</span></div>
<div><span style="color:rgb(0,0,0)"><br>
</span></div>
<div><span style="color:rgb(0,0,255)">define</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">dso_local</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">@foo</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">)
</span><span style="color:rgb(0,128,128)">local_unnamed_addr</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">#0</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">29</span><span style="color:rgb(0,0,0)"> {</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%3</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">36</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%4</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">37</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%5</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">add</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">3</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%6</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">shl</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">5</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(9,136,90)">1</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%7</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">add</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">6</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">3</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">38</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,255)">ret</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">7</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">39</span></div>
<div><span style="color:rgb(0,0,0)">}</span></div>
<div><span style="color:rgb(0,0,0)"><br>
</span></div>
<div><span style="color:rgb(0,0,255)">define</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">dso_local</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">@bar</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(0,128,128)">nocapture</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">readonly</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">)
</span><span style="color:rgb(0,128,128)">local_unnamed_addr</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">#0</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">40</span><span style="color:rgb(0,0,0)"> {</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%3</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">47</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">alias.scope</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">48</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%4</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">load</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">*
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(0,128,128)">align</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">51</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">tbaa</span><span style="color:rgb(0,0,0)">
!</span><span style="color:rgb(9,136,90)">20</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">noalias</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">48</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%5</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">add</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">4</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">3</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%6</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">shl</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">5</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(9,136,90)">1</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(205,49,49)">%7</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">=</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,0,255)">add</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">6</span><span style="color:rgb(0,0,0)">,
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">3</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">52</span></div>
<div><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,255)">ret</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(0,128,128)">i32</span><span style="color:rgb(0,0,0)">
</span><span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">7</span><span style="color:rgb(0,0,0)">, !</span><span style="color:rgb(0,128,128)">dbg</span><span style="color:rgb(0,0,0)"> !</span><span style="color:rgb(9,136,90)">53</span></div>
<div><span style="color:rgb(0,0,0)">}</span></div>
</div>
</div>
</div>
<div><br>
</div>
<div>The issue is that CSE just looks at two loads from the same location and goes 'hey I can combine them!' but it doesn't take into account whether either load has extra aliasing information or not. So in foo it has turned a noalias pointer into an aliasing
one, but in bar it has turned an aliasing pointer into a non-aliasing one.</div>
<div><br>
</div>
<div>I'm not sure what the C spec says (if anything) about this, but for us we'd like the behaviour to be defined.</div>
<div><br>
</div>
<div>Does anyone have any opinions on solving this before I drop a patch?</div>
<div>Should we perhaps make the behaviour to choose (alias over non-alias, or vice versa) controllable via a hidden CSE option?</div>
<div>What should we do in the presence of two conflicting sets of noalias information?</div>
<div><br>
</div>
<div>Sidenote: I'm aware of the 'full restrict' patch that has been circulated, but irrespective of whether that lands or not we'd still like to have some defined behaviour for the above case.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>-Neil.<br>
</div>
<div>-- <br>
<div dir="ltr">
<div dir="ltr">
<table style="border-collapse:collapse;border-spacing:0px;color:rgb(90,90,91);font-size:13px;margin:0px 0px 20px;padding:0px" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody style="margin:0px;padding:0px">
<tr style="margin:0px;padding:0px">
<td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px 0px 20px;vertical-align:top" align="left">
<table style="border-collapse:collapse;border-spacing:0px;margin:0px;padding:0px" cellspacing="0" cellpadding="0" border="0" align="left">
<tbody style="margin:0px;padding:0px">
<tr style="margin:0px;padding:0px">
<td style="border-collapse:collapse;font-size:1.12em;line-height:1.5em;padding:0px;vertical-align:top;width:64px">
<img style="border: medium none; border-radius: 0px; display: block; font-size: 13px; height: auto; line-height: 100%; margin: 0px; max-width: 100%; outline-style: none; outline-width: medium; padding: 20px 0px 0px; width: 100%;" alt="" src="https://unity3d.com/profiles/unity3d/themes/unity/images/ui/other/unity-logo-dark-email.png" width="64" height="auto"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="margin:0px;padding:0px">
<td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left">
<div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;font-weight:600;line-height:15px;margin:0px;padding:0px">
Neil Henning</div>
</td>
</tr>
<tr style="margin:0px;padding:0px">
<td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left">
<div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;line-height:15px;margin:0px;padding:0px 0px 10px">
Senior Software Engineer Compiler</div>
</td>
</tr>
<tr style="margin:0px;padding:0px">
<td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left">
<div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:12px;line-height:15px;margin:0px;padding:0px">
<a href="http://unity.com" target="_blank">unity.com</a></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><table style="border-collapse:collapse;border-spacing:0px;color:rgb(90,90,91);font-size:13px;margin:0px 0px 20px;padding:0px" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px 0px 20px;vertical-align:top" align="left"><table style="border-collapse:collapse;border-spacing:0px;margin:0px;padding:0px" cellspacing="0" cellpadding="0" border="0" align="left"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:1.12em;line-height:1.5em;padding:0px;vertical-align:top;width:64px"><img style="border: medium none; border-radius: 0px; display: block; font-size: 13px; height: auto; line-height: 100%; margin: 0px; max-width: 100%; outline-style: none; outline-width: medium; padding: 20px 0px 0px; width: 100%;" alt="" src="https://unity3d.com/profiles/unity3d/themes/unity/images/ui/other/unity-logo-dark-email.png" width="64" height="auto"></td></tr></tbody></table></td></tr><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;font-weight:600;line-height:15px;margin:0px;padding:0px">Neil Henning</div></td></tr><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;line-height:15px;margin:0px;padding:0px 0px 10px">Senior Software Engineer Compiler</div></td></tr><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:12px;line-height:15px;margin:0px;padding:0px"><a href="http://unity.com" target="_blank">unity.com</a></div></td></tr></tbody></table></div></div>