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

Robert Lougher rob.lougher at gmail.com
Thu Jan 30 08:39:04 PST 2014


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



More information about the llvm-commits mailing list