<div dir="ltr">On 12 September 2013 01:17, Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<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"><div class="im"><span style="color:rgb(34,34,34)">Say somebody really wrote:</span><br>
</div>
<br>
v0 = 7 * A[i];<br>
v1 = 7 * A[i+1];<br>
v2 = 7 * A[i+2];<br>
v3 = 7 * A[i+3];<br>
r += (v0 + v1) +  (v2 + v3);<br><br>
VS.<br>
<br>
v0 = 7 * A[i];<br>
v1 = 7 * A[i+1];<br>
v2 = 7 * A[i+2];<br>
v3 = 7 * A[i+3];<br>
r += (v0 + v2) +  (v1 + v3);<br>
<br>
In this case the order dictates which pattern to use. It is just in the fast-math case that the order does not matter.<br></blockquote><div></div></div><br></div><div class="gmail_extra">Arnold,</div><div class="gmail_extra">
<br></div><div class="gmail_extra">When you compared the two IR pieces in your original email I thought that the second was only more explicit, but they should generate the same machine code in the end, ie. the back-end should see that the instruction is redundant and not even emit it (or remove it afterwards).</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Your example above reinforces it, since the user could write a number of combinations, all of them correct, only some of them redundant, and it'd be a shame to not vectorize most patterns just because they're assumed to be free-or-nothing in the vectorizer.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">So, maybe there could be a DCE pass that would look at "shuffle vec, <0,1, undef, undef>" and know that it's free, and don't emit anything, just alias the register, no?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Does any of that makes sense?</div><div class="gmail_extra"><br></div><div class="gmail_extra">cheers,</div><div class="gmail_extra">--renato</div><div class="gmail_extra">
<br></div><div class="gmail_extra"><br></div></div>