[x86] Enable the new vector shuffle lowering by default.
[oota-llvm.git] / test / CodeGen / X86 / vec_extract.ll
1 ; RUN: llc < %s -mcpu=corei7 -march=x86 -mattr=+sse2,-sse4.1 | FileCheck %s
2
3 define void @test1(<4 x float>* %F, float* %f) nounwind {
4 ; CHECK-LABEL: test1:
5 ; CHECK:       # BB#0: # %entry
6 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
7 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %ecx
8 ; CHECK-NEXT:    movaps (%ecx), %xmm0
9 ; CHECK-NEXT:    addps %xmm0, %xmm0
10 ; CHECK-NEXT:    movss %xmm0, (%eax)
11 ; CHECK-NEXT:    retl
12 entry:
13         %tmp = load <4 x float>* %F             ; <<4 x float>> [#uses=2]
14         %tmp7 = fadd <4 x float> %tmp, %tmp             ; <<4 x float>> [#uses=1]
15         %tmp2 = extractelement <4 x float> %tmp7, i32 0         ; <float> [#uses=1]
16         store float %tmp2, float* %f
17         ret void
18 }
19
20 define float @test2(<4 x float>* %F, float* %f) nounwind {
21 ; CHECK-LABEL: test2:
22 ; CHECK:       # BB#0: # %entry
23 ; CHECK-NEXT:    pushl %eax
24 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
25 ; CHECK-NEXT:    movaps (%eax), %xmm0
26 ; CHECK-NEXT:    addps %xmm0, %xmm0
27 ; CHECK-NEXT:    shufpd {{.*#+}} xmm0 = xmm0[1,0]
28 ; CHECK-NEXT:    movss %xmm0, (%esp)
29 ; CHECK-NEXT:    flds (%esp)
30 ; CHECK-NEXT:    popl %eax
31 ; CHECK-NEXT:    retl
32 entry:
33         %tmp = load <4 x float>* %F             ; <<4 x float>> [#uses=2]
34         %tmp7 = fadd <4 x float> %tmp, %tmp             ; <<4 x float>> [#uses=1]
35         %tmp2 = extractelement <4 x float> %tmp7, i32 2         ; <float> [#uses=1]
36         ret float %tmp2
37 }
38
39 define void @test3(float* %R, <4 x float>* %P1) nounwind {
40 ; CHECK-LABEL: test3:
41 ; CHECK:       # BB#0: # %entry
42 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
43 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %ecx
44 ; CHECK-NEXT:    movss 12(%ecx), %xmm0
45 ; CHECK-NEXT:    movss %xmm0, (%eax)
46 ; CHECK-NEXT:    retl
47 entry:
48         %X = load <4 x float>* %P1              ; <<4 x float>> [#uses=1]
49         %tmp = extractelement <4 x float> %X, i32 3             ; <float> [#uses=1]
50         store float %tmp, float* %R
51         ret void
52 }
53
54 define double @test4(double %A) nounwind {
55 ; CHECK-LABEL: test4:
56 ; CHECK:       # BB#0: # %entry
57 ; CHECK-NEXT:    subl $12, %esp
58 ; CHECK-NEXT:    calll foo
59 ; CHECK-NEXT:    shufpd {{.*#+}} xmm0 = xmm0[1,0]
60 ; CHECK-NEXT:    addsd {{[0-9]+}}(%esp), %xmm0
61 ; CHECK-NEXT:    movsd %xmm0, (%esp)
62 ; CHECK-NEXT:    fldl (%esp)
63 ; CHECK-NEXT:    addl $12, %esp
64 ; CHECK-NEXT:    retl
65 entry:
66         %tmp1 = call <2 x double> @foo( )               ; <<2 x double>> [#uses=1]
67         %tmp2 = extractelement <2 x double> %tmp1, i32 1                ; <double> [#uses=1]
68         %tmp3 = fadd double %tmp2, %A           ; <double> [#uses=1]
69         ret double %tmp3
70 }
71
72 declare <2 x double> @foo()