<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 15, 2014 at 11:04 AM, Nadav Rotem <span dir="ltr"><<a href="mailto:nrotem@apple.com" target="_blank">nrotem@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Filipe,<br>
<br>
Why is this an IR-level transform? Could you implement this in SelectionDAG ?<br>
<br>
Thanks,<br>
Nadav<br>
<div class=""><div class="h5"><br>
On Apr 15, 2014, at 10:48 AM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:<br>
<br>
> +Nadav<br>
><br>
> Hi Filipe,<br>
><br>
> I like the idea of this transform. Nadav will have a better idea than I about whether this is the right place to go about it.<br>
><br>
> -Jim<br>
><br>
> On Apr 14, 2014, at 7:52 PM, Filipe Cabecinhas <<a href="mailto:filcab%2Bllvm.phabricator@gmail.com">filcab+llvm.phabricator@gmail.com</a>> wrote:<br>
><br>
>> Updated the patch to add range merging, generating fewer insertqi when possible.<br>
>><br>
>> This also allows us to find more places to do the first opt.<br>
>><br>
>> Hi grosbach,<br>
>><br>
>> <a href="http://reviews.llvm.org/D3357" target="_blank">http://reviews.llvm.org/D3357</a><br>
>><br>
>> CHANGE SINCE LAST DIFF<br>
>> <a href="http://reviews.llvm.org/D3357?vs=8482&id=8521#toc" target="_blank">http://reviews.llvm.org/D3357?vs=8482&id=8521#toc</a><br>
>><br>
>> Files:<br>
>> lib/Transforms/InstCombine/InstCombineCalls.cpp<br>
>> test/Transforms/InstCombine/vec_demanded_elts.ll<br>
>> <D3357.2.patch><br>
><br>
<br>
</div></div></blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Hi Nadav,<div><br></div><div>I'm not as familiar with SelectionDAG, but would it be able to fold N uses of insertqi easily? Doing this on instcombine allows us to, for example, easily fold these into one insertqi:</div>
<div><br></div><div>-------------------------</div><div><div>declare <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64>, <2 x i64>, i8, i8)<br></div><div><br></div><div>define <2 x i64> @testInsert64v_2(<2 x i64> %v, <2 x i64> %i) {</div>
<div>  %1 = tail call <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64> %v, <2 x i64> %i, i8 16, i8 0)</div><div>  %2 = tail call <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64> %1, <2 x i64> %i, i8 20, i8 5)</div>
<div>  %3 = tail call <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64> %2, <2 x i64> %i, i8 32, i8 25)</div><div>  %4 = tail call <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64> %3, <2 x i64> %i, i8 10, i8 52)</div>
<div>  ret <2 x i64> %4</div><div>}</div></div><div>-------------------------<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">If you add 2 to the 10 on the %4 call, you event get them all folded to a ret %i.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">If you still think it's preferable to implement it in SelectionDAG, let me know and I'll change the patch.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
Thanks,</div><div class="gmail_extra"><br clear="all"><div>  Filipe<br></div><br></div></div></div>