<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>Not specifically on the topic you ask about, but we do have some
general advice on IR features to prefer vs avoid here:
<a class="moz-txt-link-freetext" href="https://llvm.org/docs/Frontend/PerformanceTips.html">https://llvm.org/docs/Frontend/PerformanceTips.html</a></p>
<p>Philip<br>
</p>
<div class="moz-cite-prefix">On 11/22/21 7:05 AM, Jean Perier via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:MN2PR12MB4255764423DE5FC8E691E437DB9F9@MN2PR12MB4255.namprd12.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal">I would like to understand better the
implications of using loads and stores with struct types in
LLVM IR.<o:p></o:p></p>
<p class="MsoNormal">It seems that using loads and stores on
struct types leads to troubles as the struct size grows
(detailed observations below).<o:p></o:p></p>
<p class="MsoNormal">Hence my questions:<o:p></o:p></p>
<p class="MsoNormal">- Is it reasonable/better to use stores and
loads with some struct types or should llvm.memcpy always be
preferred ?<o:p></o:p></p>
<p class="MsoNormal">- Is there an official limitation on the
size of struct types that can be used in load and store
operations ?
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance for the guidance,<o:p></o:p></p>
<p class="MsoNormal">Jean Perier<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here are more details about what I have
observed with struct type loads and stores. Take the example:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><i> </i><i><span lang="FR">%t = type { [N
x i8] }<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="FR"> define void @foo(%t*
%0, %t* %1) {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="FR"> %3 = load %t, %t* %1<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="FR"> store %t %3, %t* %0<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="FR"> ret void<o:p></o:p></span></i></p>
<p class="MsoNormal"><i> }<o:p></o:p></i></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I noticed that:<o:p></o:p></p>
<p class="MsoNormal">- llc compile times are not linear at all
with `N` (with a debug build on a powerful machine, N=100
-> 0.05s, N=500 -> 1.4s, N = 1000 -> 2.25s, N = 2000
: 12.5s. … N= 65535 : more than 22 minutes, I did not wait).<o:p></o:p></p>
<p class="MsoNormal">- llc hits a first assert when `N` >=
65536 (at [1] in the code, reported 10 years ago in bug [2]).<o:p></o:p></p>
<p class="MsoNormal">- llc hits a different assert when `N`
>= 2097153 (at [3] in the code, reported a year ago in
bugs [4])<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">All this leads me to question if I should
produce LLVM IR that loads/stores struct types, or just always
use llvm.memcpy for them. Why is it allowed to load/store them
if it can lead to trouble ?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1] <a
href="https://github.com/llvm/llvm-project/blob/4c484f11d355e4293f7b245a9330f0a1e89630ac/llvm/include/llvm/CodeGen/SelectionDAGNodes.h#L1069"
moz-do-not-send="true">
https://github.com/llvm/llvm-project/blob/4c484f11d355e4293f7b245a9330f0a1e89630ac/llvm/include/llvm/CodeGen/SelectionDAGNodes.h#L1069</a><o:p></o:p></p>
<p class="MsoNormal">[2] <a
href="https://bugs.llvm.org/show_bug.cgi?id=7250"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=7250</a>
and more recently duplicated in
<a href="https://bugs.llvm.org/show_bug.cgi?id=37000"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=37000</a><o:p></o:p></p>
<p class="MsoNormal">[3] <a
href="https://github.com/llvm/llvm-project/blob/4c484f11d355e4293f7b245a9330f0a1e89630ac/llvm/lib/IR/Type.cpp#L315"
moz-do-not-send="true">
https://github.com/llvm/llvm-project/blob/4c484f11d355e4293f7b245a9330f0a1e89630ac/llvm/lib/IR/Type.cpp#L315</a><o:p></o:p></p>
<p class="MsoNormal">[4] <a
href="https://bugs.llvm.org/show_bug.cgi?id=48615"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=48615</a>
and
<a href="https://bugs.llvm.org/show_bug.cgi?id=50913"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=50913</a><o:p></o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</body>
</html>