<div dir="ltr">How could we use insertelement here?<div>Should we just (on the clang side) bitcast the vectors to <128 x i1> and use extractelement + insertelement?</div><div>That seems… hard to match on the output side.</div>
<div><br></div><div>The instruction copies _bits_ from one vector to another. We can special-case it when we're copying from an 8/16/32/64 bit boundary, for a multiple of that amount of bits, but doing the generic instruction in IR doesn't seem that easy to do.</div>
<div><br></div><div>I've also looked a bit more at SelectionDAG and I think it might be worth it to move this optimization there. But I don't know if it could handle the sequence of insertqi -> copy source vector, when the insertqi ranges add up to [0,64).</div>
<div><br></div><div>Which of these would be better?</div><div><br></div><div>Regards,</div><div>  Filipe</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 23, 2014 at 9:16 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Sent from my iPhone<br>
<div><div class="h5"><br>
> On Apr 23, 2014, at 12:08, Nadav Rotem <<a href="mailto:nrotem@apple.com">nrotem@apple.com</a>> wrote:<br>
><br>
><br>
>> On Apr 23, 2014, at 6:56 AM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
>><br>
>>> On 15 April 2014 14:04, Nadav Rotem <<a href="mailto:nrotem@apple.com">nrotem@apple.com</a>> wrote:<br>
>>> Hi Filipe,<br>
>>><br>
>>> Why is this an IR-level transform? Could you implement this in SelectionDAG ?<br>
>><br>
>> What is the advantage of doing this at SelectionDAG? Since this is an<br>
>> intrinsic, we know all that we need at the IR level already. IR also<br>
>> has the advantage of opening the potential for further optimizations<br>
> It is not clear to me why we represent this intrinsic as an IR-level intrinsic and not as a regular insertelement instruction. We already have IR-level optimizations on insertelement and I prefer not to duplicate all of them.<br>

><br>
<br>
</div></div>That I fully agree with. If the operation can be represented with generic ir that is by far the best solution.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
>> an has much better testing than SelecetionDAG.<br>
>><br>
>> Cheers,<br>
>> Rafael<br>
><br>
</div></div></blockquote></div><br></div></div>