1; RUN: llc < %s -mtriple=x86_64-linux -mcpu=penryn -o - | FileCheck %s --check-prefix=X64
2; RUN: llc < %s -mcpu=yonah -march=x86 -mtriple=i386-linux-gnu -o - | FileCheck %s --check-prefix=X32
3
4; PR7518
5define void @test1(<2 x float> %Q, float *%P2) nounwind {
6; X64-LABEL: test1:
7; X64:       # BB#0:
8; X64-NEXT:    movaps %xmm0, %xmm1
9; X64-NEXT:    shufps {{.*#+}} xmm1 = xmm1[1,1,2,3]
10; X64-NEXT:    addss %xmm0, %xmm1
11; X64-NEXT:    movss %xmm1, (%rdi)
12; X64-NEXT:    retq
13;
14; X32-LABEL: test1:
15; X32:       # BB#0:
16; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
17; X32-NEXT:    movaps %xmm0, %xmm1
18; X32-NEXT:    shufps {{.*#+}} xmm1 = xmm1[1,1,2,3]
19; X32-NEXT:    addss %xmm0, %xmm1
20; X32-NEXT:    movss %xmm1, (%eax)
21; X32-NEXT:    retl
22  %a = extractelement <2 x float> %Q, i32 0
23  %b = extractelement <2 x float> %Q, i32 1
24  %c = fadd float %a, %b
25  store float %c, float* %P2
26  ret void
27}
28
29define <2 x float> @test2(<2 x float> %Q, <2 x float> %R, <2 x float> *%P) nounwind {
30; X64-LABEL: test2:
31; X64:       # BB#0:
32; X64-NEXT:    addps %xmm1, %xmm0
33; X64-NEXT:    retq
34;
35; X32-LABEL: test2:
36; X32:       # BB#0:
37; X32-NEXT:    addps %xmm1, %xmm0
38; X32-NEXT:    retl
39  %Z = fadd <2 x float> %Q, %R
40  ret <2 x float> %Z
41}
42
43define <2 x float> @test3(<4 x float> %A) nounwind {
44; X64-LABEL: test3:
45; X64:       # BB#0:
46; X64-NEXT:    addps %xmm0, %xmm0
47; X64-NEXT:    retq
48;
49; X32-LABEL: test3:
50; X32:       # BB#0:
51; X32-NEXT:    addps %xmm0, %xmm0
52; X32-NEXT:    retl
53	%B = shufflevector <4 x float> %A, <4 x float> undef, <2 x i32> <i32 0, i32 1>
54	%C = fadd <2 x float> %B, %B
55	ret <2 x float> %C
56}
57
58define <2 x float> @test4(<2 x float> %A) nounwind {
59; X64-LABEL: test4:
60; X64:       # BB#0:
61; X64-NEXT:    addps %xmm0, %xmm0
62; X64-NEXT:    retq
63;
64; X32-LABEL: test4:
65; X32:       # BB#0:
66; X32-NEXT:    addps %xmm0, %xmm0
67; X32-NEXT:    retl
68	%C = fadd <2 x float> %A, %A
69	ret <2 x float> %C
70}
71
72define <4 x float> @test5(<4 x float> %A) nounwind {
73; X64-LABEL: test5:
74; X64:       # BB#0:
75; X64-NEXT:    addps %xmm0, %xmm0
76; X64-NEXT:    addps %xmm0, %xmm0
77; X64-NEXT:    retq
78;
79; X32-LABEL: test5:
80; X32:       # BB#0:
81; X32-NEXT:    addps %xmm0, %xmm0
82; X32-NEXT:    addps %xmm0, %xmm0
83; X32-NEXT:    retl
84	%B = shufflevector <4 x float> %A, <4 x float> undef, <2 x i32> <i32 0, i32 1>
85	%C = fadd <2 x float> %B, %B
86  br label %BB
87
88BB:
89  %D = fadd <2 x float> %C, %C
90	%E = shufflevector <2 x float> %D, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
91	ret <4 x float> %E
92}
93
94
95