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