1 ; Test memset in cases where the set value is variable. 2 ; 3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5 declare void @llvm.memset.p0i8.i32(i8 *nocapture, i8, i32, i32, i1) nounwind 6 declare void @llvm.memset.p0i8.i64(i8 *nocapture, i8, i64, i32, i1) nounwind 7 8 ; No bytes, i32 version. 9 define void @f1(i8 *%dest, i8 %val) { 10 ; CHECK-LABEL: f1: 11 ; CHECK-NOT: %r2 12 ; CHECK-NOT: %r3 13 ; CHECK: br %r14 14 call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 0, i32 1, i1 false) 15 ret void 16 } 17 18 ; No bytes, i64 version. 19 define void @f2(i8 *%dest, i8 %val) { 20 ; CHECK-LABEL: f2: 21 ; CHECK-NOT: %r2 22 ; CHECK-NOT: %r3 23 ; CHECK: br %r14 24 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 0, i32 1, i1 false) 25 ret void 26 } 27 28 ; 1 byte, i32 version. 29 define void @f3(i8 *%dest, i8 %val) { 30 ; CHECK-LABEL: f3: 31 ; CHECK: stc %r3, 0(%r2) 32 ; CHECK: br %r14 33 call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 1, i32 1, i1 false) 34 ret void 35 } 36 37 ; 1 byte, i64 version. 38 define void @f4(i8 *%dest, i8 %val) { 39 ; CHECK-LABEL: f4: 40 ; CHECK: stc %r3, 0(%r2) 41 ; CHECK: br %r14 42 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 1, i32 1, i1 false) 43 ret void 44 } 45 46 ; 2 bytes, i32 version. 47 define void @f5(i8 *%dest, i8 %val) { 48 ; CHECK-LABEL: f5: 49 ; CHECK-DAG: stc %r3, 0(%r2) 50 ; CHECK-DAG: stc %r3, 1(%r2) 51 ; CHECK: br %r14 52 call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 2, i32 1, i1 false) 53 ret void 54 } 55 56 ; 2 bytes, i64 version. 57 define void @f6(i8 *%dest, i8 %val) { 58 ; CHECK-LABEL: f6: 59 ; CHECK-DAG: stc %r3, 0(%r2) 60 ; CHECK-DAG: stc %r3, 1(%r2) 61 ; CHECK: br %r14 62 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 2, i32 1, i1 false) 63 ret void 64 } 65 66 ; 3 bytes, i32 version. 67 define void @f7(i8 *%dest, i8 %val) { 68 ; CHECK-LABEL: f7: 69 ; CHECK: stc %r3, 0(%r2) 70 ; CHECK: mvc 1(2,%r2), 0(%r2) 71 ; CHECK: br %r14 72 call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 3, i32 1, i1 false) 73 ret void 74 } 75 76 ; 3 bytes, i64 version. 77 define void @f8(i8 *%dest, i8 %val) { 78 ; CHECK-LABEL: f8: 79 ; CHECK: stc %r3, 0(%r2) 80 ; CHECK: mvc 1(2,%r2), 0(%r2) 81 ; CHECK: br %r14 82 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 3, i32 1, i1 false) 83 ret void 84 } 85 86 ; 257 bytes, i32 version. 87 define void @f9(i8 *%dest, i8 %val) { 88 ; CHECK-LABEL: f9: 89 ; CHECK: stc %r3, 0(%r2) 90 ; CHECK: mvc 1(256,%r2), 0(%r2) 91 ; CHECK: br %r14 92 call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 257, i32 1, i1 false) 93 ret void 94 } 95 96 ; 257 bytes, i64 version. 97 define void @f10(i8 *%dest, i8 %val) { 98 ; CHECK-LABEL: f10: 99 ; CHECK: stc %r3, 0(%r2) 100 ; CHECK: mvc 1(256,%r2), 0(%r2) 101 ; CHECK: br %r14 102 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 257, i32 1, i1 false) 103 ret void 104 } 105 106 ; 258 bytes, i32 version. We need two MVCs. 107 define void @f11(i8 *%dest, i8 %val) { 108 ; CHECK-LABEL: f11: 109 ; CHECK: stc %r3, 0(%r2) 110 ; CHECK: mvc 1(256,%r2), 0(%r2) 111 ; CHECK: mvc 257(1,%r2), 256(%r2) 112 ; CHECK: br %r14 113 call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 258, i32 1, i1 false) 114 ret void 115 } 116 117 ; 258 bytes, i64 version. 118 define void @f12(i8 *%dest, i8 %val) { 119 ; CHECK-LABEL: f12: 120 ; CHECK: stc %r3, 0(%r2) 121 ; CHECK: mvc 1(256,%r2), 0(%r2) 122 ; CHECK: mvc 257(1,%r2), 256(%r2) 123 ; CHECK: br %r14 124 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 258, i32 1, i1 false) 125 ret void 126 } 127 128 ; Test the largest case for which straight-line code is used. 129 define void @f13(i8 *%dest, i8 %val) { 130 ; CHECK-LABEL: f13: 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) 138 ; CHECK: br %r14 139 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 1537, i32 1, 140 i1 false) 141 ret void 142 } 143 144 ; Test the next size up, which uses a loop. We leave the other corner 145 ; cases to memcpy-01.ll. 146 define void @f14(i8 *%dest, i8 %val) { 147 ; CHECK-LABEL: f14: 148 ; CHECK: stc %r3, 0(%r2) 149 ; CHECK: lghi [[COUNT:%r[0-5]]], 6 150 ; CHECK: [[LABEL:\.L[^:]*]]: 151 ; CHECK: pfd 2, 769(%r2) 152 ; CHECK: mvc 1(256,%r2), 0(%r2) 153 ; CHECK: la %r2, 256(%r2) 154 ; CHECK: brctg [[COUNT]], [[LABEL]] 155 ; CHECK: mvc 1(1,%r2), 0(%r2) 156 ; CHECK: br %r14 157 call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 1538, i32 1, 158 i1 false) 159 ret void 160 } 161