<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">If you see the LLVM IR output, the second line is lowered into a load/store of an int. Maybe that's why.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><a href="https://godbolt.org/z/u3VyAM">https://godbolt.org/z/u3VyAM</a><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I'm not sure what the strict aliasing rules say about this, though.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">HTH</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 18, 2020 at 10:16 PM Venkataramanan Kumar via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</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 dir="ltr"><div><div><div><br></div><div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">----Snip--<br>struct st1{<br>  int a;<br>};<br>struct st2{<br>  int b;<br>};<br>struct st { <br>  struct st1 obj1; <br>  struct st2 obj2;<br>}Obj;<br><br>int test1(struct st1 * ptr1 , struct st2 * ptr2, struct st2 *ptr3) {<br>  ptr1->a = 10; <br>  *ptr3 = *ptr2;<br>  return ptr1->a;<br>}<br>--Snip---<br><br>For the above case GCC is able to store forward the value 10 to the return place.<br>LLVM is not doing this. <br>GCC<br><a href="https://godbolt.org/z/FCjCXy" target="_blank">https://godbolt.org/z/FCjCXy</a>  <br>LLVM <br><a href="https://godbolt.org/z/TFgnig" target="_blank">https://godbolt.org/z/TFgnig</a><br><br>My understanding is that under strict aliasing rules accessing objects of different types don't alias.  <br>In this case we are accessing  "struct st2" object and "int" type object. so aliasing should not prevent the forwarding of store 10 to the return place .<br><br>Can someone please clarify this?</p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><br>regards,<br>Venkat.<br></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt"></p></div><div>: </div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>