<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 03/05/2015 06:16 PM, Mircea Trofin
wrote:<br>
</div>
<blockquote
cite="mid:CAM7-JzaYYnX37GJH98oBheg5Oyfp+RJEk_dJVDn0GsbiZV2tFw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Thanks!</div>
<div><br>
</div>
Philip, do you mean I should transform the original IR to
something like this? </div>
</blockquote>
<br>
Yes.
<blockquote
cite="mid:CAM7-JzaYYnX37GJH98oBheg5Oyfp+RJEk_dJVDn0GsbiZV2tFw@mail.gmail.com"
type="cite">
<div dir="ltr">(...which is what -expand-struct-regs can do, when
applied to my original input)<br>
</div>
</blockquote>
Sorry, what? This doesn't appear to be a pass in ToT. Are you
using an older version of LLVM? If so, none of my comments will
apply. <br>
<blockquote
cite="mid:CAM7-JzaYYnX37GJH98oBheg5Oyfp+RJEk_dJVDn0GsbiZV2tFw@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div><font face="monospace, monospace">define void
@main(%struct* byval %ptr) {</font></div>
<div><font face="monospace, monospace"> %val.index =
getelementptr %struct* %ptr, i32 0, i32 0</font></div>
<div><font face="monospace, monospace"> %val.field = load i32*
%val.index</font></div>
<div><font face="monospace, monospace"> %val.index1 =
getelementptr %struct* %ptr, i32 0, i32 1</font></div>
<div><font face="monospace, monospace"> %val.field2 = load i32*
%val.index1</font></div>
<div><font face="monospace, monospace"> %val.ptr = alloca
%struct</font></div>
<div><font face="monospace, monospace"> %val.ptr.index =
getelementptr %struct* %val.ptr, i32 0, i32 0</font></div>
<div><font face="monospace, monospace"> store i32 %val.field,
i32* %val.ptr.index</font></div>
<div><font face="monospace, monospace"> %val.ptr.index4 =
getelementptr %struct* %val.ptr, i32 0, i32 1</font></div>
<div><font face="monospace, monospace"> store i32 %val.field2,
i32* %val.ptr.index4</font></div>
<div><font face="monospace, monospace"> call void
@extern_func(%struct* byval %val.ptr)</font></div>
<div><font face="monospace, monospace"> ret void</font></div>
<div><font face="monospace, monospace">}</font></div>
<div><br>
</div>
<div>If so, would you mind pointing me to the phase that would
reduce this? (I'm assuming that's what you meant by "for free"
- there's an existing phase I could use)</div>
</div>
</blockquote>
I would expect GVN to get this. If you can run this through a fully
-O3 pass order and get the right result, isolating the pass in
question should be easy. <br>
<blockquote
cite="mid:CAM7-JzaYYnX37GJH98oBheg5Oyfp+RJEk_dJVDn0GsbiZV2tFw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Thank you.</div>
<div>Mircea.</div>
<div> </div>
<br>
<div class="gmail_quote">On Thu, Mar 5, 2015 at 4:39 PM Philip
Reames <<a moz-do-not-send="true"
href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Reid is right that this would go in memcpyopt, but...
we there's an active discussion on the commit list which
will solve this through a different mechanism. There's
an active desire to avoid teaching GVN and related
pieces (of which memcpyopt is one) about first class
aggregates. We don't have enough active users of the
feature to justify and maintain the complexity. <br>
<br>
If you haven't already seen it, this background may
help:
<a moz-do-not-send="true"
href="http://llvm.org/docs/Frontend/PerformanceTips.html#avoid-loads-and-stores-of-large-aggregate-type"
target="_blank">http://llvm.org/docs/Frontend/PerformanceTips.html#avoid-loads-and-stores-of-large-aggregate-type</a><br>
<br>
The current proposal is to convert such aggregate loads
and stores into their component pieces. If that
happens, you're example should come "for free" provided
that the same example works when you break down the FCA
into it's component pieces. If it doesn't, please say
so. <br>
</div>
</div>
<div bgcolor="#FFFFFF" text="#000000">
<div> <br>
Philip</div>
</div>
<div bgcolor="#FFFFFF" text="#000000">
<div><br>
<br>
On 03/05/2015 04:21 PM, Reid Kleckner wrote:<br>
</div>
</div>
<div bgcolor="#FFFFFF" text="#000000">
<blockquote type="cite">
<div dir="ltr">I think lib/Transforms/Scalar/MemCpyOptimizer.cpp
might be the right place for this, considering that
most frontends will use memcpy for that copy anyway.
It already has some logic for byval args.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Mar 5, 2015 at 3:51
PM, Mircea Trofin <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:mtrofin@google.com" target="_blank">mtrofin@google.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">Hello all,
<div><br>
</div>
<div>I'm trying to find the pass that would
convert from:</div>
<div>
<div><br>
</div>
<div><font face="monospace, monospace">define
void @main(%struct* byval %ptr) {</font></div>
<div><font face="monospace, monospace"> %val
= load %struct* %ptr</font></div>
<div><font face="monospace, monospace">
%val.ptr = alloca %struct</font></div>
<div><font face="monospace, monospace"> store
%struct %val, %struct* %val.ptr</font></div>
<div><font face="monospace, monospace"> call
void @extern_func(%struct* byval %val.ptr)</font></div>
<div><font face="monospace, monospace"> ret
void</font></div>
<div><font face="monospace, monospace">}</font></div>
</div>
<div><br>
</div>
<div>to this:</div>
<div>
<div><font face="monospace, monospace">define
void @main(%struct* byval %ptr) {</font></div>
<div><font face="monospace, monospace"> call
void @extern_func(%struct* byval %ptr)</font></div>
<div><font face="monospace, monospace"> ret
void</font></div>
<div><font face="monospace, monospace">}</font></div>
</div>
<div><br>
</div>
<div>First, am I missing something - would this
be a correct optimization?</div>
<div><br>
</div>
<div>Thank you,</div>
<div>Mircea.</div>
</div>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a moz-do-not-send="true"
href="mailto:LLVMdev@cs.uiuc.edu"
target="_blank">LLVMdev@cs.uiuc.edu</a> <a
moz-do-not-send="true"
href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a moz-do-not-send="true"
href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>