xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/memcpy-2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mattr=+sse2      -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE2-Darwin
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mattr=+sse2      -mtriple=i686-pc-mingw32 -mcpu=core2 | FileCheck %s -check-prefix=SSE2-Mingw32
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mattr=+sse,-sse2 -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE1
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mattr=-sse       -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=NOSSE
5*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s                 -mtriple=x86_64-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=X86-64
6*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s                 -mtriple=x86_64-apple-darwin -mcpu=nehalem | FileCheck %s -check-prefix=NHM_64
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker@.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"
10*9880d681SAndroid Build Coastguard Worker@.str2 = internal constant [30 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00", align 4
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine void @t1(i32 %argc, i8** %argv) nounwind  {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin-LABEL: t1:
15*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movsd _.str+16, %xmm0
16*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movsd %xmm0, 16(%esp)
17*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movaps _.str, %xmm0
18*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movaps %xmm0
19*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movb $0, 24(%esp)
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32-LABEL: t1:
22*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movsd _.str+16, %xmm0
23*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movsd %xmm0, 16(%esp)
24*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movaps _.str, %xmm0
25*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movups %xmm0
26*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movb $0, 24(%esp)
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; SSE1-LABEL: t1:
29*9880d681SAndroid Build Coastguard Worker; SSE1: movaps _.str, %xmm0
30*9880d681SAndroid Build Coastguard Worker; SSE1: movaps %xmm0
31*9880d681SAndroid Build Coastguard Worker; SSE1: movb $0, 24(%esp)
32*9880d681SAndroid Build Coastguard Worker; SSE1: movl $0, 20(%esp)
33*9880d681SAndroid Build Coastguard Worker; SSE1: movl $0, 16(%esp)
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Worker; NOSSE-LABEL: t1:
36*9880d681SAndroid Build Coastguard Worker; NOSSE: movb $0
37*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $0
38*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $0
39*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $0
40*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $0
41*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $101
42*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $1734438249
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker; X86-64-LABEL: t1:
45*9880d681SAndroid Build Coastguard Worker; X86-64: movaps _.str(%rip), %xmm0
46*9880d681SAndroid Build Coastguard Worker; X86-64: movaps %xmm0
47*9880d681SAndroid Build Coastguard Worker; X86-64: movb $0
48*9880d681SAndroid Build Coastguard Worker; X86-64: movq $0
49*9880d681SAndroid Build Coastguard Worker  %tmp1 = alloca [25 x i8]
50*9880d681SAndroid Build Coastguard Worker  %tmp2 = bitcast [25 x i8]* %tmp1 to i8*
51*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i32 0, i32 0), i32 25, i32 1, i1 false)
52*9880d681SAndroid Build Coastguard Worker  unreachable
53*9880d681SAndroid Build Coastguard Worker}
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker;rdar://7774704
56*9880d681SAndroid Build Coastguard Worker%struct.s0 = type { [2 x double] }
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerdefine void @t2(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp {
59*9880d681SAndroid Build Coastguard Workerentry:
60*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin-LABEL: t2:
61*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movaps (%ecx), %xmm0
62*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movaps %xmm0, (%eax)
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32-LABEL: t2:
65*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movaps (%ecx), %xmm0
66*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movaps %xmm0, (%eax)
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker; SSE1-LABEL: t2:
69*9880d681SAndroid Build Coastguard Worker; SSE1: movaps (%ecx), %xmm0
70*9880d681SAndroid Build Coastguard Worker; SSE1: movaps %xmm0, (%eax)
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Worker; NOSSE-LABEL: t2:
73*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
74*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
75*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
76*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
77*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
78*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
79*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
80*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
81*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
82*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
83*9880d681SAndroid Build Coastguard Worker
84*9880d681SAndroid Build Coastguard Worker; X86-64-LABEL: t2:
85*9880d681SAndroid Build Coastguard Worker; X86-64: movaps (%rsi), %xmm0
86*9880d681SAndroid Build Coastguard Worker; X86-64: movaps %xmm0, (%rdi)
87*9880d681SAndroid Build Coastguard Worker  %tmp2 = bitcast %struct.s0* %a to i8*           ; <i8*> [#uses=1]
88*9880d681SAndroid Build Coastguard Worker  %tmp3 = bitcast %struct.s0* %b to i8*           ; <i8*> [#uses=1]
89*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 16, i1 false)
90*9880d681SAndroid Build Coastguard Worker  ret void
91*9880d681SAndroid Build Coastguard Worker}
92*9880d681SAndroid Build Coastguard Worker
93*9880d681SAndroid Build Coastguard Workerdefine void @t3(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp {
94*9880d681SAndroid Build Coastguard Workerentry:
95*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin-LABEL: t3:
96*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movsd (%ecx), %xmm0
97*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movsd 8(%ecx), %xmm1
98*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movsd %xmm1, 8(%eax)
99*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movsd %xmm0, (%eax)
100*9880d681SAndroid Build Coastguard Worker
101*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32-LABEL: t3:
102*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movsd (%ecx), %xmm0
103*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movsd 8(%ecx), %xmm1
104*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movsd %xmm1, 8(%eax)
105*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movsd %xmm0, (%eax)
106*9880d681SAndroid Build Coastguard Worker
107*9880d681SAndroid Build Coastguard Worker; SSE1-LABEL: t3:
108*9880d681SAndroid Build Coastguard Worker; SSE1: movl
109*9880d681SAndroid Build Coastguard Worker; SSE1: movl
110*9880d681SAndroid Build Coastguard Worker; SSE1: movl
111*9880d681SAndroid Build Coastguard Worker; SSE1: movl
112*9880d681SAndroid Build Coastguard Worker; SSE1: movl
113*9880d681SAndroid Build Coastguard Worker; SSE1: movl
114*9880d681SAndroid Build Coastguard Worker; SSE1: movl
115*9880d681SAndroid Build Coastguard Worker; SSE1: movl
116*9880d681SAndroid Build Coastguard Worker; SSE1: movl
117*9880d681SAndroid Build Coastguard Worker; SSE1: movl
118*9880d681SAndroid Build Coastguard Worker
119*9880d681SAndroid Build Coastguard Worker; NOSSE-LABEL: t3:
120*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
121*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
122*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
123*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
124*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
125*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
126*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
127*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
128*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
129*9880d681SAndroid Build Coastguard Worker; NOSSE: movl
130*9880d681SAndroid Build Coastguard Worker
131*9880d681SAndroid Build Coastguard Worker; X86-64-LABEL: t3:
132*9880d681SAndroid Build Coastguard Worker; X86-64: movq (%rsi), %rax
133*9880d681SAndroid Build Coastguard Worker; X86-64: movq 8(%rsi), %rcx
134*9880d681SAndroid Build Coastguard Worker; X86-64: movq %rcx, 8(%rdi)
135*9880d681SAndroid Build Coastguard Worker; X86-64: movq %rax, (%rdi)
136*9880d681SAndroid Build Coastguard Worker  %tmp2 = bitcast %struct.s0* %a to i8*           ; <i8*> [#uses=1]
137*9880d681SAndroid Build Coastguard Worker  %tmp3 = bitcast %struct.s0* %b to i8*           ; <i8*> [#uses=1]
138*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 8, i1 false)
139*9880d681SAndroid Build Coastguard Worker  ret void
140*9880d681SAndroid Build Coastguard Worker}
141*9880d681SAndroid Build Coastguard Worker
142*9880d681SAndroid Build Coastguard Workerdefine void @t4() nounwind {
143*9880d681SAndroid Build Coastguard Workerentry:
144*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin-LABEL: t4:
145*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movw $120
146*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
147*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
148*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
149*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
150*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
151*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
152*9880d681SAndroid Build Coastguard Worker; SSE2-Darwin: movl $2021161080
153*9880d681SAndroid Build Coastguard Worker
154*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32-LABEL: t4:
155*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movw $120
156*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
157*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
158*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
159*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
160*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
161*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
162*9880d681SAndroid Build Coastguard Worker; SSE2-Mingw32: movl $2021161080
163*9880d681SAndroid Build Coastguard Worker
164*9880d681SAndroid Build Coastguard Worker; SSE1-LABEL: t4:
165*9880d681SAndroid Build Coastguard Worker; SSE1: movw $120
166*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
167*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
168*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
169*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
170*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
171*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
172*9880d681SAndroid Build Coastguard Worker; SSE1: movl $2021161080
173*9880d681SAndroid Build Coastguard Worker
174*9880d681SAndroid Build Coastguard Worker; NOSSE-LABEL: t4:
175*9880d681SAndroid Build Coastguard Worker; NOSSE: movw $120
176*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
177*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
178*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
179*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
180*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
181*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
182*9880d681SAndroid Build Coastguard Worker; NOSSE: movl $2021161080
183*9880d681SAndroid Build Coastguard Worker
184*9880d681SAndroid Build Coastguard Worker;;; TODO: (1) Some of the loads and stores are certainly unaligned and (2) the first load and first
185*9880d681SAndroid Build Coastguard Worker;;; store overlap with the second load and second store respectively.
186*9880d681SAndroid Build Coastguard Worker;;;
187*9880d681SAndroid Build Coastguard Worker;;; Is either of the sequences ideal?
188*9880d681SAndroid Build Coastguard Worker
189*9880d681SAndroid Build Coastguard Worker; X86-64-LABEL: t4:
190*9880d681SAndroid Build Coastguard Worker; X86-64: movabsq  $33909456017848440, %rax ## imm = 0x78787878787878
191*9880d681SAndroid Build Coastguard Worker; X86-64: movq     %rax, -10(%rsp)
192*9880d681SAndroid Build Coastguard Worker; X86-64: movabsq  $8680820740569200760, %rax ## imm = 0x7878787878787878
193*9880d681SAndroid Build Coastguard Worker; X86-64: movq     %rax, -16(%rsp)
194*9880d681SAndroid Build Coastguard Worker; X86-64: movq     %rax, -24(%rsp)
195*9880d681SAndroid Build Coastguard Worker; X86-64: movq     %rax, -32(%rsp)
196*9880d681SAndroid Build Coastguard Worker
197*9880d681SAndroid Build Coastguard Worker; NHM_64-LABEL: t4:
198*9880d681SAndroid Build Coastguard Worker; NHM_64: movups   _.str2+14(%rip), %xmm0
199*9880d681SAndroid Build Coastguard Worker; NHM_64: movups   %xmm0, -26(%rsp)
200*9880d681SAndroid Build Coastguard Worker; NHM_64: movups   _.str2(%rip), %xmm0
201*9880d681SAndroid Build Coastguard Worker; NHM_64: movaps   %xmm0, -40(%rsp)
202*9880d681SAndroid Build Coastguard Worker
203*9880d681SAndroid Build Coastguard Worker  %tmp1 = alloca [30 x i8]
204*9880d681SAndroid Build Coastguard Worker  %tmp2 = bitcast [30 x i8]* %tmp1 to i8*
205*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str2, i32 0, i32 0), i32 30, i32 1, i1 false)
206*9880d681SAndroid Build Coastguard Worker  unreachable
207*9880d681SAndroid Build Coastguard Worker}
208*9880d681SAndroid Build Coastguard Worker
209*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
210