Use movups to lower memcpy and memset even if it's not fast (like corei7).
[oota-llvm.git] / test / CodeGen / X86 / memcpy-2.ll
1 ; RUN: llc < %s -mattr=+sse2      -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE2
2 ; RUN: llc < %s -mattr=-sse       -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=NOSSE
3 ; RUN: llc < %s                 -mtriple=x86_64-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=X86-64
4
5 @.str = internal constant [25 x i8] c"image\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
6 @.str2 = internal constant [30 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00", align 4
7
8 define void @t1(i32 %argc, i8** %argv) nounwind  {
9 entry:
10 ; SSE2: t1:
11 ; SSE2: movaps _.str, %xmm0
12 ; SSE2: movaps %xmm0
13 ; SSE2: movb $0
14 ; SSE2: movl $0
15 ; SSE2: movl $0
16
17 ; NOSSE: t1:
18 ; NOSSE: movb $0
19 ; NOSSE: movl $0
20 ; NOSSE: movl $0
21 ; NOSSE: movl $0
22 ; NOSSE: movl $0
23 ; NOSSE: movl $101
24 ; NOSSE: movl $1734438249
25
26 ; X86-64: t1:
27 ; X86-64: movaps _.str(%rip), %xmm0
28 ; X86-64: movaps %xmm0
29 ; X86-64: movb $0
30 ; X86-64: movq $0
31   %tmp1 = alloca [25 x i8]
32   %tmp2 = bitcast [25 x i8]* %tmp1 to i8*
33   call void @llvm.memcpy.i32( i8* %tmp2, i8* getelementptr ([25 x i8]* @.str, i32 0, i32 0), i32 25, i32 1 ) nounwind 
34   unreachable
35 }
36
37 ;rdar://7774704
38 %struct.s0 = type { [2 x double] }
39
40 define void @t2(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp {
41 entry:
42 ; SSE2: t2:
43 ; SSE2: movaps (%eax), %xmm0
44 ; SSE2: movaps %xmm0, (%eax)
45
46 ; NOSSE: t2:
47 ; NOSSE: movl
48 ; NOSSE: movl
49 ; NOSSE: movl
50 ; NOSSE: movl
51 ; NOSSE: movl
52 ; NOSSE: movl
53 ; NOSSE: movl
54 ; NOSSE: movl
55 ; NOSSE: movl
56 ; NOSSE: movl
57
58 ; X86-64: t2:
59 ; X86-64: movaps (%rsi), %xmm0
60 ; X86-64: movaps %xmm0, (%rdi)
61   %tmp2 = bitcast %struct.s0* %a to i8*           ; <i8*> [#uses=1]
62   %tmp3 = bitcast %struct.s0* %b to i8*           ; <i8*> [#uses=1]
63   tail call void @llvm.memcpy.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 16)
64   ret void
65 }
66
67 define void @t3(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp {
68 entry:
69 ; SSE2: t3:
70 ; SSE2: movups (%eax), %xmm0
71 ; SSE2: movups %xmm0, (%eax)
72
73 ; NOSSE: t3:
74 ; NOSSE: movl
75 ; NOSSE: movl
76 ; NOSSE: movl
77 ; NOSSE: movl
78 ; NOSSE: movl
79 ; NOSSE: movl
80 ; NOSSE: movl
81 ; NOSSE: movl
82 ; NOSSE: movl
83 ; NOSSE: movl
84
85 ; X86-64: t3:
86 ; X86-64: movups (%rsi), %xmm0
87 ; X86-64: movups %xmm0, (%rdi)
88   %tmp2 = bitcast %struct.s0* %a to i8*           ; <i8*> [#uses=1]
89   %tmp3 = bitcast %struct.s0* %b to i8*           ; <i8*> [#uses=1]
90   tail call void @llvm.memcpy.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 8)
91   ret void
92 }
93
94 define void @t4() nounwind {
95 entry:
96 ; SSE2: t4:
97 ; SSE2: movups _.str2, %xmm0
98 ; SSE2: movaps %xmm0, (%esp)
99 ; SSE2: movw $120, 28(%esp)
100 ; SSE2: movl $2021161080
101 ; SSE2: movl $2021161080
102 ; SSE2: movl $2021161080
103
104 ; NOSSE: t4:
105 ; NOSSE: movw $120
106 ; NOSSE: movl $2021161080
107 ; NOSSE: movl $2021161080
108 ; NOSSE: movl $2021161080
109 ; NOSSE: movl $2021161080
110 ; NOSSE: movl $2021161080
111 ; NOSSE: movl $2021161080
112 ; NOSSE: movl $2021161080
113
114 ; X86-64: t4:
115 ; X86-64: movabsq $8680820740569200760, %rax
116 ; X86-64: movq %rax
117 ; X86-64: movups _.str2(%rip), %xmm0
118 ; X86-64: movaps %xmm0, -40(%rsp)
119 ; X86-64: movw $120
120 ; X86-64: movl $2021161080
121   %tmp1 = alloca [30 x i8]
122   %tmp2 = bitcast [30 x i8]* %tmp1 to i8*
123   call void @llvm.memcpy.i32(i8* %tmp2, i8* getelementptr inbounds ([30 x i8]* @.str2, i32 0, i32 0), i32 30, i32 1)
124   unreachable
125 }
126
127 declare void @llvm.memcpy.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind