<div dir="ltr">Hi Nadav,<div><br></div><div>I'd really like this patch to get in, since it improves code generation on many targets (at the very least, I've tried arm and arm64 (mcpu=cyclone), ppc32 and ppc64 (mcpu=g5), and x86 and x86-64 (mcpu=nehalem) and they all improve (they end up with no loads vs. 1 or 2 loads, and code size is about half of what it was).</div>
<div><br></div><div>Even if we'd like to make the select instruction be the proper canonicalization of this operation, it seems that, for now, a shufflevector is better when it comes to lowering it.</div><div><br></div>
<div>Several targets have the action for the vselect as Expand, which will generate a bunch of code which would then have to be pattern-matched, instead of lowering the vselect as custom and falling-through to Expand if there's no special-case instruction/set of instructions that we can emit.</div>
<div><br></div><div>I ran opt+llc in this way, for the variants I mentioned above (./bin/opt is opt with this optimization):</div><div>./bin/opt -O3 select-from-shuffles.ll | ./bin/llc -march=arm64 -mcpu=cyclone > arm64-cylone-opt<br>
</div><div>opt -O3 select-from-shuffles.ll | ./bin/llc -march=arm64 -mcpu=cyclone > arm64-cylone-opt<br></div><div><br></div><div>I can understand if we eventually drop this after we make the backend treat the select as the canonical form of this operation and have llvm always use that form, but for now it seems that the shufflevector is better lowered in some important targets.</div>
<div><br></div><div><br></div><div>  Filipe</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 2, 2014 at 11:55 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Filipe,<br>
<br>
We don’t generate new shufflevector instructions during optimizations because the lowering of shuffle instructions is really complicated and we don’t want to generate a shuffle that we don’t lower by accident.<br>
<br>
Thanks,<br>
Nadav<br>
<div><div class="h5"><br>
On May 2, 2014, at 4:34 PM, Filipe Cabecinhas <<a href="mailto:filcab%2Bllvm.phabricator@gmail.com">filcab+llvm.phabricator@gmail.com</a>> wrote:<br>
<br>
> Remove unused argument<br>
><br>
> <a href="http://reviews.llvm.org/D3561" target="_blank">http://reviews.llvm.org/D3561</a><br>
><br>
> Files:<br>
>  lib/Transforms/InstCombine/InstCombineSelect.cpp<br>
>  test/Transforms/InstCombine/select.ll<br>
</div></div>> <D3561.9050.patch>_______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote></div><br></div>