[PATCH] Teach the DAGCombiner how to fold insert_subvector nodes with concat_vectors input

Manman Ren manman.ren at gmail.com
Thu Jan 30 10:46:50 PST 2014


LGTM except one nit:
+
+  // If the input vector is a concatenation, and the insert replaces
+  // one of the halves, we can optimize into a single concat_vectors

The comment should end with a period :)

Thanks,
Manman


On Thu, Jan 30, 2014 at 8:39 AM, Robert Lougher <rob.lougher at gmail.com>wrote:

> ping.
>
> On 23 January 2014 19:57, Robert Lougher <rob.lougher at gmail.com> wrote:
> > Hi,
> >
> > This patch teaches the DAGCombiner how to fold insert_subvector nodes
> > when the input is a concat_vectors and the insert replaces one of the
> > concat halves:
> >
> > Lower half: fold (insert_subvector (concat_vectors X, Y), Z) ->
> > (concat_vectors Z, Y)
> > Upper half: fold (insert_subvector (concat_vectors X, Y), Z) ->
> > (concat_vectors X, Z)
> >
> > This can be seen with the following IR:
> >
> > define <8 x float> @lower_half(<4 x float> %v1, <4 x float> %v2, <4 x
> > float> %v3) {
> >   %1 = shufflevector <4 x float> %v1, <4 x float> %v2, <8 x i32> <i32
> > 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
> >   %2 = tail call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x
> > float> %1, <4 x float> %v3, i8 0)
> >
> > The vinsertf128 intrinsic is converted into an insert_subvector node
> > in SelectionDAGBuilder.cpp.
> >
> > Using AVX, without the patch this generates two vinsertf128 instructions:
> >
> > vinsertf128 $1, %xmm1, %ymm0, %ymm0
> > vinsertf128 $0, %xmm2, %ymm0, %ymm0
> >
> > With the patch this is optimized into:
> >
> > vinsertf128 $1, %xmm1, %ymm2, %ymm0
> >
> >
> > I have added a test that checks both the upper and lower halves.  If
> > the patch looks OK please submit for me.
> >
> > Thanks,
> > Rob.
> >
> > --
> > Robert Lougher
> > SN Systems - Sony Computer Entertainment Group
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140130/410a79c9/attachment.html>


More information about the llvm-commits mailing list