1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s
3
4define <4 x i32> @trunc_64_32(<4 x i64> %A) nounwind uwtable readnone ssp{
5; CHECK-LABEL: trunc_64_32:
6; CHECK:       ## BB#0:
7; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
8; CHECK-NEXT:    vpshufd {{.*#+}} xmm1 = xmm1[0,1,0,2]
9; CHECK-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
10; CHECK-NEXT:    vpblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[4,5,6,7]
11; CHECK-NEXT:    vzeroupper
12; CHECK-NEXT:    retq
13  %B = trunc <4 x i64> %A to <4 x i32>
14  ret <4 x i32>%B
15}
16
17define <8 x i16> @trunc_32_16(<8 x i32> %A) nounwind uwtable readnone ssp{
18; CHECK-LABEL: trunc_32_16:
19; CHECK:       ## BB#0:
20; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
21; CHECK-NEXT:    vmovdqa {{.*#+}} xmm2 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
22; CHECK-NEXT:    vpshufb %xmm2, %xmm1, %xmm1
23; CHECK-NEXT:    vpshufb %xmm2, %xmm0, %xmm0
24; CHECK-NEXT:    vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
25; CHECK-NEXT:    vzeroupper
26; CHECK-NEXT:    retq
27  %B = trunc <8 x i32> %A to <8 x i16>
28  ret <8 x i16>%B
29}
30
31define <16 x i8> @trunc_16_8(<16 x i16> %A) nounwind uwtable readnone ssp{
32; CHECK-LABEL: trunc_16_8:
33; CHECK:       ## BB#0:
34; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
35; CHECK-NEXT:    vmovdqa {{.*#+}} xmm2 = <0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u>
36; CHECK-NEXT:    vpshufb %xmm2, %xmm1, %xmm1
37; CHECK-NEXT:    vpshufb %xmm2, %xmm0, %xmm0
38; CHECK-NEXT:    vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
39; CHECK-NEXT:    vzeroupper
40; CHECK-NEXT:    retq
41  %B = trunc <16 x i16> %A to <16 x i8>
42  ret <16 x i8> %B
43}
44