1; RUN: llc < %s -march=x86 -mcpu=corei7 | FileCheck %s
2; RUN: llc < %s -march=x86 -mcpu=core-avx-i | FileCheck %s --check-prefix=AVX
3
4define <1 x float> @test1(<1 x double> %x) nounwind {
5; CHECK-LABEL: test1:
6; CHECK:       # BB#0:
7; CHECK-NEXT:    pushl %eax
8; CHECK-NEXT:    movsd {{[0-9]+}}(%esp), %xmm0
9; CHECK-NEXT:    cvtsd2ss %xmm0, %xmm0
10; CHECK-NEXT:    movss %xmm0, (%esp)
11; CHECK-NEXT:    flds (%esp)
12; CHECK-NEXT:    popl %eax
13; CHECK-NEXT:    retl
14;
15; AVX-LABEL: test1:
16; AVX:       # BB#0:
17; AVX-NEXT:    pushl %eax
18; AVX-NEXT:    vmovsd {{[0-9]+}}(%esp), %xmm0
19; AVX-NEXT:    vcvtsd2ss %xmm0, %xmm0, %xmm0
20; AVX-NEXT:    vmovss %xmm0, (%esp)
21; AVX-NEXT:    flds (%esp)
22; AVX-NEXT:    popl %eax
23; AVX-NEXT:    retl
24  %y = fptrunc <1 x double> %x to <1 x float>
25  ret <1 x float> %y
26}
27
28define <2 x float> @test2(<2 x double> %x) nounwind {
29; CHECK-LABEL: test2:
30; CHECK:       # BB#0:
31; CHECK-NEXT:    cvtpd2ps %xmm0, %xmm0
32; CHECK-NEXT:    retl
33;
34; AVX-LABEL: test2:
35; AVX:       # BB#0:
36; AVX-NEXT:    vcvtpd2ps %xmm0, %xmm0
37; AVX-NEXT:    retl
38  %y = fptrunc <2 x double> %x to <2 x float>
39  ret <2 x float> %y
40}
41
42define <4 x float> @test3(<4 x double> %x) nounwind {
43; CHECK-LABEL: test3:
44; CHECK:       # BB#0:
45; CHECK-NEXT:    cvtpd2ps %xmm1, %xmm1
46; CHECK-NEXT:    cvtpd2ps %xmm0, %xmm0
47; CHECK-NEXT:    unpcklpd {{.*#+}} xmm0 = xmm0[0],xmm1[0]
48; CHECK-NEXT:    retl
49;
50; AVX-LABEL: test3:
51; AVX:       # BB#0:
52; AVX-NEXT:    vcvtpd2psy %ymm0, %xmm0
53; AVX-NEXT:    vzeroupper
54; AVX-NEXT:    retl
55  %y = fptrunc <4 x double> %x to <4 x float>
56  ret <4 x float> %y
57}
58
59define <8 x float> @test4(<8 x double> %x) nounwind {
60; CHECK-LABEL: test4:
61; CHECK:       # BB#0:
62; CHECK-NEXT:    cvtpd2ps %xmm1, %xmm1
63; CHECK-NEXT:    cvtpd2ps %xmm0, %xmm0
64; CHECK-NEXT:    unpcklpd {{.*#+}} xmm0 = xmm0[0],xmm1[0]
65; CHECK-NEXT:    cvtpd2ps %xmm3, %xmm3
66; CHECK-NEXT:    cvtpd2ps %xmm2, %xmm1
67; CHECK-NEXT:    unpcklpd {{.*#+}} xmm1 = xmm1[0],xmm3[0]
68; CHECK-NEXT:    retl
69;
70; AVX-LABEL: test4:
71; AVX:       # BB#0:
72; AVX-NEXT:    vcvtpd2psy %ymm0, %xmm0
73; AVX-NEXT:    vcvtpd2psy %ymm1, %xmm1
74; AVX-NEXT:    vinsertf128 $1, %xmm1, %ymm0, %ymm0
75; AVX-NEXT:    retl
76  %y = fptrunc <8 x double> %x to <8 x float>
77  ret <8 x float> %y
78}
79
80
81