<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 15, 2014 at 3:43 AM, Andrea Di Biagio <span dir="ltr"><<a href="mailto:andrea.dibiagio@gmail.com" target="_blank">andrea.dibiagio@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 id=":3qw" class="a3s" style="overflow:hidden">I guess you are referring to this test in particular:<br>
<span class=""><br>
 ; SSE41-LABEL: @shuffle_v4f32_4zzz<br>
-; SSE41:         insertps {{.*}} # xmm0 = xmm0[0],zero,zero,zero<br>
+; SSE41:         xorps %[[X:xmm[0-9]+]], %[[X]]<br>
+; SSE41-NEXT:    blendps {{.*}} # [[X]] = xmm0[0],[[X]][1,2,3]<br>
+; SSE41-NEXT:    movaps %[[X]], %xmm0<br>
 ; SSE41-NEXT:    retq<br>
<br>
</span>If we commute the blendps then we can get rid of the extra movaps.<br></div></blockquote><div><br></div><div>Exactly.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":3qw" class="a3s" style="overflow:hidden">
<br>
Also, in this test, I am not sure if a xorps+blendps would do better<br>
than a single insertps. In case, we might want to check if one of the<br>
operands to the blend is a vector of all-zeros and prefer a single<br>
insertps instead of a xorps+blendps combo.</div></blockquote></div><br>I thought a lot about this. Agner's tables seem to indicate that 'xorps' of a register with itself is somehow crazy fast. This to a certain extent makes sense. Plus, blendps can be executed on either of 2 ports while insertps requires both ports to be occupied (for sandybridge, similarly on other architectures from what I can see). So I think we'll see higher throughput with the xorps+blendps sequence than the insertps sequence. But all this is based on Agner's tables. If you have direct measurements that indicate the reverse, its easy to fix.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I'll look at your example separatel.</div></div>