1 ; Test memset in cases where the set value is variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 declare void @llvm.memset.p0i8.i32(i8 *nocapture, i8, i32, i1) nounwind
6 declare void @llvm.memset.p0i8.i64(i8 *nocapture, i8, i64, i1) nounwind
8 ; No bytes, i32 version.
9 define void @f1(i8* %dest, i8 %val) {
14 call void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 0, i1 false)
18 ; No bytes, i64 version.
19 define void @f2(i8* %dest, i8 %val) {
24 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 0, i1 false)
28 ; 1 byte, i32 version.
29 define void @f3(i8* %dest, i8 %val) {
31 ; CHECK: stc %r3, 0(%r2)
33 call void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 1, i1 false)
37 ; 1 byte, i64 version.
38 define void @f4(i8* %dest, i8 %val) {
40 ; CHECK: stc %r3, 0(%r2)
42 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 1, i1 false)
46 ; 2 bytes, i32 version.
47 define void @f5(i8* %dest, i8 %val) {
49 ; CHECK-DAG: stc %r3, 0(%r2)
50 ; CHECK-DAG: stc %r3, 1(%r2)
52 call void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 2, i1 false)
56 ; 2 bytes, i64 version.
57 define void @f6(i8* %dest, i8 %val) {
59 ; CHECK-DAG: stc %r3, 0(%r2)
60 ; CHECK-DAG: stc %r3, 1(%r2)
62 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 2, i1 false)
66 ; 3 bytes, i32 version.
67 define void @f7(i8* %dest, i8 %val) {
69 ; CHECK: stc %r3, 0(%r2)
70 ; CHECK: mvc 1(2,%r2), 0(%r2)
72 call void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 3, i1 false)
76 ; 3 bytes, i64 version.
77 define void @f8(i8* %dest, i8 %val) {
79 ; CHECK: stc %r3, 0(%r2)
80 ; CHECK: mvc 1(2,%r2), 0(%r2)
82 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 3, i1 false)
86 ; 257 bytes, i32 version.
87 define void @f9(i8* %dest, i8 %val) {
89 ; CHECK: stc %r3, 0(%r2)
90 ; CHECK: mvc 1(256,%r2), 0(%r2)
92 call void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 257, i1 false)
96 ; 257 bytes, i64 version.
97 define void @f10(i8* %dest, i8 %val) {
99 ; CHECK: stc %r3, 0(%r2)
100 ; CHECK: mvc 1(256,%r2), 0(%r2)
102 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 257, i1 false)
106 ; 258 bytes, i32 version. We need two MVCs.
107 define void @f11(i8* %dest, i8 %val) {
109 ; CHECK: stc %r3, 0(%r2)
110 ; CHECK: mvc 1(256,%r2), 0(%r2)
111 ; CHECK: mvc 257(1,%r2), 256(%r2)
113 call void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 258, i1 false)
117 ; 258 bytes, i64 version.
118 define void @f12(i8* %dest, i8 %val) {
120 ; CHECK: stc %r3, 0(%r2)
121 ; CHECK: mvc 1(256,%r2), 0(%r2)
122 ; CHECK: mvc 257(1,%r2), 256(%r2)
124 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 258, i1 false)
128 ; Test the largest case for which straight-line code is used.
129 define void @f13(i8* %dest, i8 %val) {
131 ; CHECK: stc %r3, 0(%r2)
132 ; CHECK: mvc 1(256,%r2), 0(%r2)
133 ; CHECK: mvc 257(256,%r2), 256(%r2)
134 ; CHECK: mvc 513(256,%r2), 512(%r2)
135 ; CHECK: mvc 769(256,%r2), 768(%r2)
136 ; CHECK: mvc 1025(256,%r2), 1024(%r2)
137 ; CHECK: mvc 1281(256,%r2), 1280(%r2)
139 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 1537, i1 false)
143 ; Test the next size up, which uses a loop. We leave the other corner
144 ; cases to memcpy-01.ll.
145 define void @f14(i8* %dest, i8 %val) {
147 ; CHECK: stc %r3, 0(%r2)
148 ; CHECK: lghi [[COUNT:%r[0-5]]], 6
149 ; CHECK: [[LABEL:\.L[^:]*]]:
150 ; CHECK: pfd 2, 769(%r2)
151 ; CHECK: mvc 1(256,%r2), 0(%r2)
152 ; CHECK: la %r2, 256(%r2)
153 ; CHECK: brctg [[COUNT]], [[LABEL]]
154 ; CHECK: mvc 1(1,%r2), 0(%r2)
156 call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 1538, i1 false)