[llvm-dev] IR canonicalization: vector select or shufflevector?
Philip Reames via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 29 08:19:27 PDT 2016
I don't have a strong preference, though it is clear we should pick
one. I'd mildly prefer the select form for readability. From an
optimization standpoint, I see reasonable arguments for either.
Philip
On 08/28/2016 12:37 PM, Sanjay Patel via llvm-dev wrote:
> A vector select with a constant vector condition operand:
>
> define <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) {
> %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x
> i32> %a, <4 x i32> %b
> ret <4 x i32> %sel
> }
>
>
> ...is equivalent to a shufflevector:
>
> define <4 x i32> @goo(<4 x i32> %a, <4 x i32> %b) {
> %shuf = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0,
> i32 5, i32 6, i32 3>
> ret <4 x i32> %shuf
> }
>
>
> For the goal of canonicalization in IR, which of these should we
> prefer? Some backend / lowering differences for AArch64 and PPC are
> noted in:
> https://llvm.org/bugs/show_bug.cgi?id=28530
> https://llvm.org/bugs/show_bug.cgi?id=28531
>
> x86 converts either form optimally in all cases I've looked at.
>
> This question first came up in D22114 (
> https://reviews.llvm.org/D22114 ) and is extended in D23886 (
> https://reviews.llvm.org/D23886 ) with a constant value example.
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160829/f2bfb19d/attachment.html>
More information about the llvm-dev
mailing list