blob: 76c3fdfc060cff4a3b35b3f8ebfe9cc04c88cb62 [file] [log] [blame]
Chris Lattner11b3d162010-07-05 05:52:56 +00001; RUN: llc < %s -march=x86-64 -mcpu=penryn -asm-verbose=0 -o - | FileCheck %s -check-prefix=X64
Chris Lattner4fd1ab32010-07-05 03:56:55 +00002; RUN: llc < %s -mcpu=yonah -march=x86 -asm-verbose=0 -o - | FileCheck %s -check-prefix=X32
Chris Lattnere35d9842010-07-04 22:57:10 +00003
4; PR7518
5define void @test1(<2 x float> %Q, float *%P2) nounwind {
6 %a = extractelement <2 x float> %Q, i32 0
7 %b = extractelement <2 x float> %Q, i32 1
8 %c = fadd float %a, %b
9
10 store float %c, float* %P2
11 ret void
Chris Lattnerf172ecd2010-07-04 23:07:25 +000012; X64: test1:
Chris Lattnere6f7c262010-08-25 22:49:25 +000013; X64-NEXT: pshufd $1, %xmm0, %xmm1
14; X64-NEXT: addss %xmm0, %xmm1
15; X64-NEXT: movss %xmm1, (%rdi)
Chris Lattnerf172ecd2010-07-04 23:07:25 +000016; X64-NEXT: ret
17
18; X32: test1:
Chris Lattnere6f7c262010-08-25 22:49:25 +000019; X32-NEXT: pshufd $1, %xmm0, %xmm1
20; X32-NEXT: addss %xmm0, %xmm1
21; X32-NEXT: movl 4(%esp), %eax
22; X32-NEXT: movss %xmm1, (%eax)
Chris Lattnerf172ecd2010-07-04 23:07:25 +000023; X32-NEXT: ret
Chris Lattnere35d9842010-07-04 22:57:10 +000024}
25
Chris Lattner11b3d162010-07-05 05:52:56 +000026
27define <2 x float> @test2(<2 x float> %Q, <2 x float> %R, <2 x float> *%P) nounwind {
28 %Z = fadd <2 x float> %Q, %R
29 ret <2 x float> %Z
30
31; X64: test2:
Chris Lattnere6f7c262010-08-25 22:49:25 +000032; X64-NEXT: addps %xmm1, %xmm0
Chris Lattner11b3d162010-07-05 05:52:56 +000033; X64-NEXT: ret
34}
Chris Lattnere6f7c262010-08-25 22:49:25 +000035
36
37define <2 x float> @test3(<4 x float> %A) nounwind {
38 %B = shufflevector <4 x float> %A, <4 x float> undef, <2 x i32> <i32 0, i32 1>
39 %C = fadd <2 x float> %B, %B
40 ret <2 x float> %C
41; CHECK: test3:
42; CHECK-NEXT: addps %xmm0, %xmm0
43; CHECK-NEXT: ret
44}
45
46define <2 x float> @test4(<2 x float> %A) nounwind {
47 %C = fadd <2 x float> %A, %A
48 ret <2 x float> %C
49; CHECK: test4:
50; CHECK-NEXT: addps %xmm0, %xmm0
51; CHECK-NEXT: ret
52}
53
54define <4 x float> @test5(<4 x float> %A) nounwind {
55 %B = shufflevector <4 x float> %A, <4 x float> undef, <2 x i32> <i32 0, i32 1>
56 %C = fadd <2 x float> %B, %B
57 br label %BB
58
59BB:
60 %D = fadd <2 x float> %C, %C
61 %E = shufflevector <2 x float> %D, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
62 ret <4 x float> %E
63
64; CHECK: _test5:
65; CHECK-NEXT: addps %xmm0, %xmm0
66; CHECK-NEXT: addps %xmm0, %xmm0
67; CHECK-NEXT: ret
68}
69
70