<div dir="ltr"><div>Hi Craig</div><div> Thank you very much !<br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-30 16:11 GMT+08:00 Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The pointers must always be i8* the alignment is independent and is controlled by the attributes on the arguments in the call to memcpy.</div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all"><div><div class="m_-1229980907412180580gmail_signature" data-smartmail="gmail_signature">~Craig</div></div></font></span><div><div class="h5">
<br><div class="gmail_quote">On Mon, Jan 29, 2018 at 11:45 PM, ma jun <span dir="ltr"><<a href="mailto:jun.parser@gmail.com" target="_blank">jun.parser@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi </div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote"><span>2018-01-30 15:36 GMT+08:00 ma jun <span dir="ltr"><<a href="mailto:jun.parser@gmail.com" target="_blank">jun.parser@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div>Hi </div><div> Thanks !</div><div> so for this example </div><div>void foo(X &src, X &dst) {<br> dst = src;<br>}</div><div>and the IR:</div><div><br></div><div>define void @foo(X&, X&)(%struct.X* dereferenceable(8), %struct.X* dereferenceable(8)) #0 {<br> %3 = alloca %struct.X*, align 8<br> %4 = alloca %struct.X*, align 8<br> store %struct.X* %0, %struct.X** %3, align 8<br> store %struct.X* %1, %struct.X** %4, align 8<br> %5 = load %struct.X*, %struct.X** %3, align 8<br> %6 = load %struct.X*, %struct.X** %4, align 8<br> %7 = bitcast %struct.X* %6 to i8*<br> %8 = bitcast %struct.X* %5 to i8*<br> call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 8, i1 false)<br></div></div></blockquote><div> </div></span><div>also since the dst and src are 4 byte align , can we use the IR below:<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br></div><div>
<div class="m_-1229980907412180580m_-1240222975037371828gmail-WordSection1">
<p align="left" class="MsoNormal" style="margin:2pt 0cm;text-align:left;font-family:"Calibri",sans-serif;font-size:10.5pt;text-justify:inter-ideograph"><span lang="EN-US" style="color:rgb(205,49,49);font-family:"Times New Roman",serif;font-size:12pt">%7</span><span lang="EN-US" style="font-family:"Times New Roman",serif;font-size:12pt"> <span style="color:rgb(205,49,49)">=</span> <span style="color:blue">bitcast</span> <span style="color:teal">%struct.X</span>* <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">6</span> <span style="color:teal">to</span> <span style="color:teal"><wbr>i32</span>*</span></p>
<p align="left" class="MsoNormal" style="margin:2pt 0cm;text-align:left;font-family:"Calibri",sans-serif;font-size:10.5pt;text-justify:inter-ideograph"><span lang="EN-US" style="color:rgb(205,49,49);font-family:"Times New Roman",serif;font-size:12pt">%8</span><span lang="EN-US" style="font-family:"Times New Roman",serif;font-size:12pt"> <span style="color:rgb(205,49,49)">=</span> <span style="color:blue">bitcast</span> <span style="color:teal">%struct.X</span>* <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">5</span> <span style="color:teal">to</span> <span style="color:teal"><wbr>i32</span>*</span></p>
<p align="left" class="MsoNormal" style="margin:2pt 0cm;text-align:left;font-family:"Calibri",sans-serif;font-size:10.5pt;text-justify:inter-ideograph"><span lang="EN-US" style="color:blue;font-family:"Times New Roman",serif;font-size:12pt">call</span><span lang="EN-US" style="font-family:"Times New Roman",serif;font-size:12pt"> <span style="color:teal">void</span> <span style="color:teal">@llvm.memcpy.p0i32.p<wbr>0i32.i64</span>(<span style="color:teal">i32</span>* <span style="color:teal">align</span> <span style="color:rgb(9,136,90)">4</span> <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">7</span>, <span style="color:teal">i32</span>*<wbr> <span style="color:teal">align</span> <span style="color:rgb(9,136,90)">4</span> <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,136,90)">8</span>, <span style="color:teal">i64</span> <span style="color:rgb(9,136,90)">8</span>, <span style="color:teal">i1</span> <span style="color:teal">false</span>)</span><span lang="EN-US" style="color:black;font-family:"Times New Roman",serif;font-size:10pt"> </span></p>
</div>
</div><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div> ret void<br>}</div><div><br></div><div>how can I transform the llvm.memcpy into data move loop IR and eliminate the bitcast instruction ?</div><div><br></div><div>Regards</div><span class="m_-1229980907412180580m_-1240222975037371828gmail-HOEnZb"><font color="#888888"><div>Jun</div><div><br></div></font></span></div><div class="m_-1229980907412180580m_-1240222975037371828gmail-HOEnZb"><div class="m_-1229980907412180580m_-1240222975037371828gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-01-30 15:24 GMT+08:00 Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">The i8 type in the pointers doesn't matter a whole lot. There's a long term plan to remove the type from all pointers in llvm IR.<div><br></div><div>Yes, clang will use memcpy for struct copies. You can see example IR here <a href="https://godbolt.org/g/8gQ18m" target="_blank">https://godbolt.org/g/8gQ<wbr>18m</a>. You'll see that the struct pointers are bitcasted to i8* before the call.</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251m_-3223831155570563618gmail_signature">~Craig</div></div>
<br><div class="gmail_quote"><div><div class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251h5">On Mon, Jan 29, 2018 at 11:12 PM, ma jun via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251h5"><div dir="ltr">
<br class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251m_-3223831155570563618m_8789134829123072660gmail-Apple-interchange-newline"><span style="color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;word-spacing:0px;display:inline;white-space:normal;float:none;background-color:rgb(255,255,255)">Hi all</span><div> I'm new here, and I have some question about llvm.memcpy intrinsic.<br><div style="color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)"> why does llvm.memcpy intrinsic only support i8* for first two arguments? and does clang will also transform struct copy into llvm.memcpy ? what format does IR looks like? </div><div style="color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)"> Thanks !</div><div style="color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)"> </div><div style="color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)"> Regards</div><span class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251m_-3223831155570563618HOEnZb"><font color="#888888"><span class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251m_-3223831155570563618m_8789134829123072660gmail-HOEnZb" style="color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)"><font color="#888888"><span class="m_-1229980907412180580m_-1240222975037371828gmail-m_5455752013163073251m_-3223831155570563618m_8789134829123072660gmail-m_-3461872585872149570HOEnZb"><font color="#888888"><div> Jun</div></font></span></font></span>
<br></font></span></div></div>
<br></div></div>______________________________<wbr>_________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></span></div><br></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div>