1 ; Test memset in cases where a loop is used.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 declare void @llvm.memset.p0.i32(ptr nocapture, i8, i32, i1) nounwind
6 declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind
8 ; Constant length: 6 iterations and 2 bytes remainder.
9 define void @f1(ptr %dest, i8 %val) {
11 ; CHECK: lghi [[COUNT:%r[0-5]]], 6
12 ; CHECK: [[LABEL:\.L[^:]*]]:
13 ; CHECK: pfd 2, 768(%r2)
14 ; CHECK: stc %r3, 0(%r2)
15 ; CHECK: mvc 1(255,%r2), 0(%r2)
16 ; CHECK: la %r2, 256(%r2)
17 ; CHECK: brctg [[COUNT]], [[LABEL]]
18 ; CHECK: stc %r3, 0(%r2)
19 ; CHECK-NEXT: mvc 1(1,%r2), 0(%r2)
21 call void @llvm.memset.p0.i64(ptr %dest, i8 %val, i64 1538, i1 false)
25 ; Constant length: 6 iterations and 255 bytes remainder.
26 define void @f2(ptr %dest) {
28 ; CHECK: lghi [[COUNT:%r[0-5]]], 6
29 ; CHECK: [[LABEL:\.L[^:]*]]:
30 ; CHECK: pfd 2, 768(%r2)
31 ; CHECK: mvi 0(%r2), 1
32 ; CHECK: mvc 1(255,%r2), 0(%r2)
33 ; CHECK: la %r2, 256(%r2)
34 ; CHECK: brctg [[COUNT]], [[LABEL]]
35 ; CHECK: mvi 0(%r2), 1
36 ; CHECK-NEXT: mvc 1(254,%r2), 0(%r2)
38 call void @llvm.memset.p0.i32(ptr %dest, i8 1, i32 1791, i1 false)
42 ; Variable length, byte in register.
43 define void @f3(ptr %dest, i8 %val, i64 %Len) {
46 ; CHECK-NEXT: aghi %r4, -2
47 ; CHECK-NEXT: cgibe %r4, -2, 0(%r14)
48 ; CHECK-NEXT: .LBB2_1:
49 ; CHECK-NEXT: cgije %r4, -1, .LBB2_5
51 ; CHECK-NEXT: srlg %r0, %r4, 8
52 ; CHECK-NEXT: cgije %r0, 0, .LBB2_4
53 ; CHECK-NEXT:.LBB2_3: # =>This Inner Loop Header: Depth=1
54 ; CHECK-NEXT: pfd 2, 768(%r2)
55 ; CHECK-NEXT: stc %r3, 0(%r2)
56 ; CHECK-NEXT: mvc 1(255,%r2), 0(%r2)
57 ; CHECK-NEXT: la %r2, 256(%r2)
58 ; CHECK-NEXT: brctg %r0, .LBB2_3
60 ; CHECK-NEXT: stc %r3, 0(%r2)
61 ; CHECK-NEXT: exrl %r4, .Ltmp0
64 ; CHECK-NEXT: stc %r3, 0(%r2)
66 call void @llvm.memset.p0.i64(ptr %dest, i8 %val, i64 %Len, i1 false)
70 ; Variable length, immediate byte.
71 define void @f4(ptr %dest, i32 %Len) {
74 ; CHECK-NEXT: llgfr %r1, %r3
75 ; CHECK-NEXT: aghi %r1, -2
76 ; CHECK-NEXT: cgibe %r1, -2, 0(%r14)
78 ; CHECK-NEXT: cgije %r1, -1, .LBB3_5
80 ; CHECK-NEXT: srlg %r0, %r1, 8
81 ; CHECK-NEXT: cgije %r0, 0, .LBB3_4
82 ; CHECK-NEXT:.LBB3_3: # =>This Inner Loop Header: Depth=1
83 ; CHECK-NEXT: pfd 2, 768(%r2)
84 ; CHECK-NEXT: mvi 0(%r2), 1
85 ; CHECK-NEXT: mvc 1(255,%r2), 0(%r2)
86 ; CHECK-NEXT: la %r2, 256(%r2)
87 ; CHECK-NEXT: brctg %r0, .LBB3_3
89 ; CHECK-NEXT: mvi 0(%r2), 1
90 ; CHECK-NEXT: exrl %r1, .Ltmp0
93 ; CHECK-NEXT: mvi 0(%r2), 1
95 call void @llvm.memset.p0.i32(ptr %dest, i8 1, i32 %Len, i1 false)
100 ; CHECK-NEXT: mvc 1(1,%r2), 0(%r2)