1 ; Test memset in cases where the set value is a constant other than 0 and -1.
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) {
13 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 0, i1 false)
17 ; No bytes, i64 version.
18 define void @f2(i8* %dest) {
22 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 0, i1 false)
26 ; 1 byte, i32 version.
27 define void @f3(i8* %dest) {
29 ; CHECK: mvi 0(%r2), 128
31 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 1, i1 false)
35 ; 1 byte, i64 version.
36 define void @f4(i8* %dest) {
38 ; CHECK: mvi 0(%r2), 128
40 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 1, i1 false)
44 ; 2 bytes, i32 version.
45 define void @f5(i8* %dest) {
47 ; CHECK: mvhhi 0(%r2), -32640
49 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 2, i1 false)
53 ; 2 bytes, i64 version.
54 define void @f6(i8* %dest) {
56 ; CHECK: mvhhi 0(%r2), -32640
58 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 2, i1 false)
62 ; 3 bytes, i32 version.
63 define void @f7(i8* %dest) {
65 ; CHECK-DAG: mvhhi 0(%r2), -32640
66 ; CHECK-DAG: mvi 2(%r2), 128
68 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 3, i1 false)
72 ; 3 bytes, i64 version.
73 define void @f8(i8* %dest) {
75 ; CHECK-DAG: mvhhi 0(%r2), -32640
76 ; CHECK-DAG: mvi 2(%r2), 128
78 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 3, i1 false)
82 ; 4 bytes, i32 version.
83 define void @f9(i8* %dest) {
85 ; CHECK: iilf [[REG:%r[0-5]]], 2155905152
86 ; CHECK: st [[REG]], 0(%r2)
88 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 4, i1 false)
92 ; 4 bytes, i64 version.
93 define void @f10(i8* %dest) {
95 ; CHECK: iilf [[REG:%r[0-5]]], 2155905152
96 ; CHECK: st [[REG]], 0(%r2)
98 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 4, i1 false)
102 ; 5 bytes, i32 version.
103 define void @f11(i8* %dest) {
105 ; CHECK: mvi 0(%r2), 128
106 ; CHECK: mvc 1(4,%r2), 0(%r2)
108 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 5, i1 false)
112 ; 5 bytes, i64 version.
113 define void @f12(i8* %dest) {
115 ; CHECK: mvi 0(%r2), 128
116 ; CHECK: mvc 1(4,%r2), 0(%r2)
118 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 5, i1 false)
122 ; 257 bytes, i32 version.
123 define void @f13(i8* %dest) {
125 ; CHECK: mvi 0(%r2), 128
126 ; CHECK: mvc 1(256,%r2), 0(%r2)
128 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 257, i1 false)
132 ; 257 bytes, i64 version.
133 define void @f14(i8* %dest) {
135 ; CHECK: mvi 0(%r2), 128
136 ; CHECK: mvc 1(256,%r2), 0(%r2)
138 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 257, i1 false)
142 ; 258 bytes, i32 version. We need two MVCs.
143 define void @f15(i8* %dest) {
145 ; CHECK: mvi 0(%r2), 128
146 ; CHECK: mvc 1(256,%r2), 0(%r2)
147 ; CHECK: mvc 257(1,%r2), 256(%r2)
149 call void @llvm.memset.p0i8.i32(i8* %dest, i8 128, i32 258, i1 false)
153 ; 258 bytes, i64 version.
154 define void @f16(i8* %dest) {
156 ; CHECK: mvi 0(%r2), 128
157 ; CHECK: mvc 1(256,%r2), 0(%r2)
158 ; CHECK: mvc 257(1,%r2), 256(%r2)
160 call void @llvm.memset.p0i8.i64(i8* %dest, i8 128, i64 258, i1 false)