1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test memset 0 with variable length
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 define void @fun0(i8* %Addr, i64 %Len) {
9 ; CHECK-NEXT: aghi %r3, -1
10 ; CHECK-NEXT: cgibe %r3, -1, 0(%r14)
11 ; CHECK-NEXT: .LBB0_1:
12 ; CHECK-NEXT: srlg %r0, %r3, 8
13 ; CHECK-NEXT: cgije %r0, 0, .LBB0_3
14 ; CHECK-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=1
15 ; CHECK-NEXT: xc 0(256,%r2), 0(%r2)
16 ; CHECK-NEXT: la %r2, 256(%r2)
17 ; CHECK-NEXT: brctg %r0, .LBB0_2
18 ; CHECK-NEXT: .LBB0_3:
19 ; CHECK-NEXT: exrl %r3, .Ltmp0
21 tail call void @llvm.memset.p0i8.i64(i8* %Addr, i8 0, i64 %Len, i1 false)
25 define void @fun1(i8* %Addr, i32 %Len) {
28 ; CHECK-NEXT: llgfr %r1, %r3
29 ; CHECK-NEXT: aghi %r1, -1
30 ; CHECK-NEXT: cgibe %r1, -1, 0(%r14)
31 ; CHECK-NEXT: .LBB1_1:
32 ; CHECK-NEXT: srlg %r0, %r1, 8
33 ; CHECK-NEXT: cgije %r0, 0, .LBB1_3
34 ; CHECK-NEXT: .LBB1_2: # =>This Inner Loop Header: Depth=1
35 ; CHECK-NEXT: xc 0(256,%r2), 0(%r2)
36 ; CHECK-NEXT: la %r2, 256(%r2)
37 ; CHECK-NEXT: brctg %r0, .LBB1_2
38 ; CHECK-NEXT: .LBB1_3:
39 ; CHECK-NEXT: exrl %r1, .Ltmp0
41 tail call void @llvm.memset.p0i8.i32(i8* %Addr, i8 0, i32 %Len, i1 false)
45 ; Test that identical target instructions get reused.
46 define void @fun2(i8* %Addr, i32 %Len) {
49 ; CHECK-NEXT: llgfr %r1, %r3
50 ; CHECK-NEXT: aghi %r1, -1
51 ; CHECK-NEXT: srlg %r0, %r1, 8
52 ; CHECK-NEXT: cgije %r1, -1, .LBB2_5
53 ; CHECK-NEXT: # %bb.1:
54 ; CHECK-NEXT: lgr %r3, %r2
55 ; CHECK-NEXT: cgije %r0, 0, .LBB2_4
56 ; CHECK-NEXT: # %bb.2:
57 ; CHECK-NEXT: lgr %r3, %r2
58 ; CHECK-NEXT: lgr %r4, %r0
59 ; CHECK-NEXT: .LBB2_3: # =>This Inner Loop Header: Depth=1
60 ; CHECK-NEXT: xc 0(256,%r3), 0(%r3)
61 ; CHECK-NEXT: la %r3, 256(%r3)
62 ; CHECK-NEXT: brctg %r4, .LBB2_3
63 ; CHECK-NEXT: .LBB2_4:
64 ; CHECK-NEXT: exrl %r1, .Ltmp1
65 ; CHECK-NEXT: .LBB2_5:
66 ; CHECK-NEXT: cgije %r1, -1, .LBB2_10
67 ; CHECK-NEXT: # %bb.6:
68 ; CHECK-NEXT: lgr %r3, %r2
69 ; CHECK-NEXT: cgije %r0, 0, .LBB2_9
70 ; CHECK-NEXT: # %bb.7:
71 ; CHECK-NEXT: lgr %r3, %r2
72 ; CHECK-NEXT: lgr %r4, %r0
73 ; CHECK-NEXT: .LBB2_8: # =>This Inner Loop Header: Depth=1
74 ; CHECK-NEXT: xc 0(256,%r3), 0(%r3)
75 ; CHECK-NEXT: la %r3, 256(%r3)
76 ; CHECK-NEXT: brctg %r4, .LBB2_8
77 ; CHECK-NEXT: .LBB2_9:
78 ; CHECK-NEXT: exrl %r1, .Ltmp1
79 ; CHECK-NEXT: .LBB2_10:
80 ; CHECK-NEXT: cgibe %r1, -1, 0(%r14)
81 ; CHECK-NEXT: .LBB2_11:
82 ; CHECK-NEXT: cgije %r0, 0, .LBB2_13
83 ; CHECK-NEXT: .LBB2_12: # =>This Inner Loop Header: Depth=1
84 ; CHECK-NEXT: xc 0(256,%r2), 0(%r2)
85 ; CHECK-NEXT: la %r2, 256(%r2)
86 ; CHECK-NEXT: brctg %r0, .LBB2_12
87 ; CHECK-NEXT: .LBB2_13:
88 ; CHECK-NEXT: exrl %r1, .Ltmp0
90 tail call void @llvm.memset.p0i8.i32(i8* %Addr, i8 0, i32 %Len, i1 false)
91 tail call void @llvm.memset.p0i8.i32(i8* %Addr, i8 0, i32 %Len, i1 false)
92 tail call void @llvm.memset.p0i8.i32(i8* %Addr, i8 0, i32 %Len, i1 false)
96 ; Test that a memset to nullptr compiles.
97 define void @fun3(i64 %Len) {
100 ; CHECK-NEXT: aghi %r2, -1
101 ; CHECK-NEXT: cgibe %r2, -1, 0(%r14)
102 ; CHECK-NEXT: .LBB3_1:
103 ; CHECK-NEXT: srlg %r0, %r2, 8
104 ; CHECK-NEXT: lghi %r1, 0
105 ; CHECK-NEXT: cgije %r0, 0, .LBB3_3
106 ; CHECK-NEXT: .LBB3_2: # =>This Inner Loop Header: Depth=1
107 ; CHECK-NEXT: xc 0(256,%r1), 0(%r1)
108 ; CHECK-NEXT: la %r1, 256(%r1)
109 ; CHECK-NEXT: brctg %r0, .LBB3_2
110 ; CHECK-NEXT: .LBB3_3:
111 ; CHECK-NEXT: exrl %r2, .Ltmp2
112 ; CHECK-NEXT: br %r14
113 call void @llvm.memset.p0i8.i64(i8* null, i8 0, i64 %Len, i1 false)
118 ; CHECK-NEXT: xc 0(1,%r1), 0(%r1)
119 ; CHECK-NEXT: .Ltmp0:
120 ; CHECK-NEXT: xc 0(1,%r2), 0(%r2)
121 ; CHECK-NEXT: .Ltmp1:
122 ; CHECK-NEXT: xc 0(1,%r3), 0(%r3)
124 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
125 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg)