1; Test strlen using SRST, i64 version.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5declare i64 @strlen(i8 *%src)
6declare i64 @strnlen(i8 *%src, i64 %len)
7
8; Test strlen with its proper i64 prototype.  It would also be valid for
9; the uses of %r3 and REG after the LGR to be swapped.
10define i64 @f1(i32 %dummy, i8 *%src) {
11; CHECK-LABEL: f1:
12; CHECK-DAG: lhi %r0, 0
13; CHECK-DAG: lghi %r2, 0
14; CHECK-DAG: lgr [[REG:%r[145]]], %r3
15; CHECK: [[LABEL:\.[^:]*]]:
16; CHECK-NEXT: srst %r2, [[REG]]
17; CHECK-NEXT: jo [[LABEL]]
18; CHECK-NEXT: BB#{{[0-9]+}}
19; CHECK-NEXT: sgr %r2, %r3
20; CHECK: br %r14
21  %res = call i64 @strlen(i8 *%src)
22  ret i64 %res
23}
24
25; Test strnlen with its proper i64 prototype.
26define i64 @f2(i64 %len, i8 *%src) {
27; CHECK-LABEL: f2:
28; CHECK-DAG: agr %r2, %r3
29; CHECK-DAG: lhi %r0, 0
30; CHECK-DAG: lgr [[REG:%r[145]]], %r3
31; CHECK: [[LABEL:\.[^:]*]]:
32; CHECK-NEXT: srst %r2, [[REG]]
33; CHECK-NEXT: jo [[LABEL]]
34; CHECK-NEXT: BB#{{[0-9]+}}
35; CHECK-NEXT: sgr %r2, %r3
36; CHECK: br %r14
37  %res = call i64 @strnlen(i8 *%src, i64 %len)
38  ret i64 %res
39}
40