xref: /llvm-project/llvm/test/CodeGen/X86/memset.ll (revision adc6a9e8189cc0a8a02a2fcea3f820ea2b402251)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mcpu=pentium2 -mtriple=i686-apple-darwin8.8.0 | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mcpu=pentium3 -mtriple=i686-apple-darwin8.8.0 | FileCheck %s --check-prefix=XMM
4; RUN: llc < %s -mcpu=bdver1   -mtriple=i686-apple-darwin8.8.0 | FileCheck %s --check-prefix=YMM
5
6%struct.x = type { i16, i16 }
7
8define void @t() nounwind  {
9; X86-LABEL: t:
10; X86:       ## %bb.0: ## %entry
11; X86-NEXT:    subl $44, %esp
12; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
13; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
14; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
15; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
16; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
17; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
18; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
19; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
20; X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
21; X86-NEXT:    movl %eax, (%esp)
22; X86-NEXT:    calll _foo
23; X86-NEXT:    addl $44, %esp
24; X86-NEXT:    retl
25;
26; XMM-LABEL: t:
27; XMM:       ## %bb.0: ## %entry
28; XMM-NEXT:    subl $60, %esp
29; XMM-NEXT:    xorps %xmm0, %xmm0
30; XMM-NEXT:    movaps %xmm0, {{[0-9]+}}(%esp)
31; XMM-NEXT:    movaps %xmm0, {{[0-9]+}}(%esp)
32; XMM-NEXT:    leal {{[0-9]+}}(%esp), %eax
33; XMM-NEXT:    movl %eax, (%esp)
34; XMM-NEXT:    calll _foo
35; XMM-NEXT:    addl $60, %esp
36; XMM-NEXT:    retl
37;
38; YMM-LABEL: t:
39; YMM:       ## %bb.0: ## %entry
40; YMM-NEXT:    subl $60, %esp
41; YMM-NEXT:    leal {{[0-9]+}}(%esp), %eax
42; YMM-NEXT:    vxorps %xmm0, %xmm0, %xmm0
43; YMM-NEXT:    vmovups %ymm0, {{[0-9]+}}(%esp)
44; YMM-NEXT:    movl %eax, (%esp)
45; YMM-NEXT:    vzeroupper
46; YMM-NEXT:    calll _foo
47; YMM-NEXT:    addl $60, %esp
48; YMM-NEXT:    retl
49entry:
50	%up_mvd = alloca [8 x %struct.x]		; <ptr> [#uses=2]
51	%up_mvd116 = getelementptr [8 x %struct.x], ptr %up_mvd, i32 0, i32 0		; <ptr> [#uses=1]
52
53	call void @llvm.memset.p0.i64(ptr align 8 %up_mvd, i8 0, i64 32, i1 false)
54	call void @foo( ptr %up_mvd116 ) nounwind
55	ret void
56}
57
58declare void @foo(ptr)
59
60declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind
61
62; Ensure that alignment of '0' in an @llvm.memset intrinsic results in
63; unaligned loads and stores.
64define void @PR15348(ptr %a) {
65; X86-LABEL: PR15348:
66; X86:       ## %bb.0:
67; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
68; X86-NEXT:    movb $0, 16(%eax)
69; X86-NEXT:    movl $0, 12(%eax)
70; X86-NEXT:    movl $0, 8(%eax)
71; X86-NEXT:    movl $0, 4(%eax)
72; X86-NEXT:    movl $0, (%eax)
73; X86-NEXT:    retl
74;
75; XMM-LABEL: PR15348:
76; XMM:       ## %bb.0:
77; XMM-NEXT:    movl {{[0-9]+}}(%esp), %eax
78; XMM-NEXT:    movb $0, 16(%eax)
79; XMM-NEXT:    movl $0, 12(%eax)
80; XMM-NEXT:    movl $0, 8(%eax)
81; XMM-NEXT:    movl $0, 4(%eax)
82; XMM-NEXT:    movl $0, (%eax)
83; XMM-NEXT:    retl
84;
85; YMM-LABEL: PR15348:
86; YMM:       ## %bb.0:
87; YMM-NEXT:    movl {{[0-9]+}}(%esp), %eax
88; YMM-NEXT:    vxorps %xmm0, %xmm0, %xmm0
89; YMM-NEXT:    vmovups %xmm0, (%eax)
90; YMM-NEXT:    movb $0, 16(%eax)
91; YMM-NEXT:    retl
92  call void @llvm.memset.p0.i64(ptr %a, i8 0, i64 17, i1 false)
93  ret void
94}
95
96declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg)
97
98define void @PR83077(ptr %a) {
99; X86-LABEL: PR83077:
100; X86:       ## %bb.0:
101; X86-NEXT:    pushl %edi
102; X86-NEXT:    .cfi_def_cfa_offset 8
103; X86-NEXT:    .cfi_offset %edi, -8
104; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
105; X86-NEXT:    movl $-1, %eax
106; X86-NEXT:    movl $22, %ecx
107; X86-NEXT:    movl %edx, %edi
108; X86-NEXT:    rep;stosl %eax, %es:(%edi)
109; X86-NEXT:    movw $-1, 88(%edx)
110; X86-NEXT:    popl %edi
111; X86-NEXT:    retl
112;
113; XMM-LABEL: PR83077:
114; XMM:       ## %bb.0:
115; XMM-NEXT:    pushl %edi
116; XMM-NEXT:    .cfi_def_cfa_offset 8
117; XMM-NEXT:    .cfi_offset %edi, -8
118; XMM-NEXT:    movl {{[0-9]+}}(%esp), %edx
119; XMM-NEXT:    movl $-1, %eax
120; XMM-NEXT:    movl $22, %ecx
121; XMM-NEXT:    movl %edx, %edi
122; XMM-NEXT:    rep;stosl %eax, %es:(%edi)
123; XMM-NEXT:    movw $-1, 88(%edx)
124; XMM-NEXT:    popl %edi
125; XMM-NEXT:    retl
126;
127; YMM-LABEL: PR83077:
128; YMM:       ## %bb.0:
129; YMM-NEXT:    movl {{[0-9]+}}(%esp), %eax
130; YMM-NEXT:    vxorps %xmm0, %xmm0, %xmm0
131; YMM-NEXT:    vcmptrueps %ymm0, %ymm0, %ymm0
132; YMM-NEXT:    vmovups %ymm0, 58(%eax)
133; YMM-NEXT:    vmovups %ymm0, 32(%eax)
134; YMM-NEXT:    vmovups %ymm0, (%eax)
135; YMM-NEXT:    vzeroupper
136; YMM-NEXT:    retl
137  call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(90) %a, i8 -1, i32 90, i1 false)
138  ret void
139}
140