X86: Enable SSE memory intrinsics even when stack alignment is less than 16 bytes.
[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=+sse2      -mtriple=i686-pc-mingw32 -mcpu=core2 | FileCheck %s -check-prefix=SSE2
3 ; RUN: llc < %s -mattr=+sse,-sse2 -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE1
4 ; RUN: llc < %s -mattr=-sse       -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=NOSSE
5 ; RUN: llc < %s                 -mtriple=x86_64-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=X86-64
6
7 @.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"
8 @.str2 = internal constant [30 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00", align 4
9
10 define void @t1(i32 %argc, i8** %argv) nounwind  {
11 entry:
12 ; SSE2: t1:
13 ; SSE2: movaps _.str, %xmm0
14 ; SSE2: movaps %xmm0
15 ; SSE2: movb $0
16 ; SSE2: movl $0
17 ; SSE2: movl $0
18
19 ; SSE1: t1:
20 ; SSE1: movaps _.str, %xmm0
21 ; SSE1: movaps %xmm0
22 ; SSE1: movb $0
23 ; SSE1: movl $0
24 ; SSE1: movl $0
25
26 ; NOSSE: t1:
27 ; NOSSE: movb $0
28 ; NOSSE: movl $0
29 ; NOSSE: movl $0
30 ; NOSSE: movl $0
31 ; NOSSE: movl $0
32 ; NOSSE: movl $101
33 ; NOSSE: movl $1734438249
34
35 ; X86-64: t1:
36 ; X86-64: movaps _.str(%rip), %xmm0
37 ; X86-64: movaps %xmm0
38 ; X86-64: movb $0
39 ; X86-64: movq $0
40   %tmp1 = alloca [25 x i8]
41   %tmp2 = bitcast [25 x i8]* %tmp1 to i8*
42   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* getelementptr inbounds ([25 x i8]* @.str, i32 0, i32 0), i32 25, i32 1, i1 false)
43   unreachable
44 }
45
46 ;rdar://7774704
47 %struct.s0 = type { [2 x double] }
48
49 define void @t2(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp {
50 entry:
51 ; SSE2: t2:
52 ; SSE2: movaps (%eax), %xmm0
53 ; SSE2: movaps %xmm0, (%eax)
54
55 ; SSE1: t2:
56 ; SSE1: movaps (%eax), %xmm0
57 ; SSE1: movaps %xmm0, (%eax)
58
59 ; NOSSE: t2:
60 ; NOSSE: movl
61 ; NOSSE: movl
62 ; NOSSE: movl
63 ; NOSSE: movl
64 ; NOSSE: movl
65 ; NOSSE: movl
66 ; NOSSE: movl
67 ; NOSSE: movl
68 ; NOSSE: movl
69 ; NOSSE: movl
70
71 ; X86-64: t2:
72 ; X86-64: movaps (%rsi), %xmm0
73 ; X86-64: movaps %xmm0, (%rdi)
74   %tmp2 = bitcast %struct.s0* %a to i8*           ; <i8*> [#uses=1]
75   %tmp3 = bitcast %struct.s0* %b to i8*           ; <i8*> [#uses=1]
76   tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 16, i1 false)
77   ret void
78 }
79
80 define void @t3(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp {
81 entry:
82 ; SSE2: t3:
83 ; SSE2: movsd (%eax), %xmm0
84 ; SSE2: movsd 8(%eax), %xmm1
85 ; SSE2: movsd %xmm1, 8(%eax)
86 ; SSE2: movsd %xmm0, (%eax)
87
88 ; SSE1: t3:
89 ; SSE1: movl
90 ; SSE1: movl
91 ; SSE1: movl
92 ; SSE1: movl
93 ; SSE1: movl
94 ; SSE1: movl
95 ; SSE1: movl
96 ; SSE1: movl
97 ; SSE1: movl
98 ; SSE1: movl
99
100 ; NOSSE: t3:
101 ; NOSSE: movl
102 ; NOSSE: movl
103 ; NOSSE: movl
104 ; NOSSE: movl
105 ; NOSSE: movl
106 ; NOSSE: movl
107 ; NOSSE: movl
108 ; NOSSE: movl
109 ; NOSSE: movl
110 ; NOSSE: movl
111
112 ; X86-64: t3:
113 ; X86-64: movq (%rsi), %rax
114 ; X86-64: movq 8(%rsi), %rcx
115 ; X86-64: movq %rcx, 8(%rdi)
116 ; X86-64: movq %rax, (%rdi)
117   %tmp2 = bitcast %struct.s0* %a to i8*           ; <i8*> [#uses=1]
118   %tmp3 = bitcast %struct.s0* %b to i8*           ; <i8*> [#uses=1]
119   tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 8, i1 false)
120   ret void
121 }
122
123 define void @t4() nounwind {
124 entry:
125 ; SSE2: t4:
126 ; SSE2: movw $120
127 ; SSE2: movl $2021161080
128 ; SSE2: movl $2021161080
129 ; SSE2: movl $2021161080
130 ; SSE2: movl $2021161080
131 ; SSE2: movl $2021161080
132 ; SSE2: movl $2021161080
133 ; SSE2: movl $2021161080
134
135 ; SSE1: t4:
136 ; SSE1: movw $120
137 ; SSE1: movl $2021161080
138 ; SSE1: movl $2021161080
139 ; SSE1: movl $2021161080
140 ; SSE1: movl $2021161080
141 ; SSE1: movl $2021161080
142 ; SSE1: movl $2021161080
143 ; SSE1: movl $2021161080
144
145 ; NOSSE: t4:
146 ; NOSSE: movw $120
147 ; NOSSE: movl $2021161080
148 ; NOSSE: movl $2021161080
149 ; NOSSE: movl $2021161080
150 ; NOSSE: movl $2021161080
151 ; NOSSE: movl $2021161080
152 ; NOSSE: movl $2021161080
153 ; NOSSE: movl $2021161080
154
155 ; X86-64: t4:
156 ; X86-64: movabsq $8680820740569200760, %rax
157 ; X86-64: movq %rax
158 ; X86-64: movq %rax
159 ; X86-64: movq %rax
160 ; X86-64: movw $120
161 ; X86-64: movl $2021161080
162   %tmp1 = alloca [30 x i8]
163   %tmp2 = bitcast [30 x i8]* %tmp1 to i8*
164   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* getelementptr inbounds ([30 x i8]* @.str2, i32 0, i32 0), i32 30, i32 1, i1 false)
165   unreachable
166 }
167
168 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind