1 ; Test memchr using SRST, with the correct prototype.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -no-integrated-as | FileCheck %s
5 declare i8 *@memchr(i8 *%src, i32 %char, i64 %len)
7 ; Test a simple forwarded call.
8 define i8 *@f1(i64 %len, i8 *%src, i32 %char) {
10 ; CHECK-DAG: agr %r2, %r3
11 ; CHECK-DAG: llcr %r0, %r4
12 ; CHECK: [[LABEL:\.[^:]*]]:
13 ; CHECK: srst %r2, %r3
14 ; CHECK-NEXT: jo [[LABEL]]
18 %res = call i8 *@memchr(i8 *%src, i32 %char, i64 %len)
22 ; Test a doubled call with no use of %r0 in between. There should be a
24 define i8 *@f2(i8 *%src, i8 *%charptr, i64 %len) {
26 ; CHECK: llc %r0, 0(%r3)
28 ; CHECK: srst [[RES1:%r[1-5]]], %r2
30 ; CHECK: srst %r2, [[RES1]]
32 %char = load volatile i8, i8 *%charptr
33 %charext = zext i8 %char to i32
34 %res1 = call i8 *@memchr(i8 *%src, i32 %charext, i64 %len)
35 %res2 = call i8 *@memchr(i8 *%res1, i32 %charext, i64 %len)
39 ; Test a doubled call with a use of %r0 in between. %r0 must be loaded
41 define i8 *@f3(i8 *%src, i8 *%charptr, i64 %len) {
43 ; CHECK: llc [[CHAR:%r[1-5]]], 0(%r3)
44 ; CHECK: lr %r0, [[CHAR]]
45 ; CHECK: srst [[RES1:%r[1-5]]], %r2
48 ; CHECK: lr %r0, [[CHAR]]
49 ; CHECK: srst %r2, [[RES1]]
51 %char = load volatile i8, i8 *%charptr
52 %charext = zext i8 %char to i32
53 %res1 = call i8 *@memchr(i8 *%src, i32 %charext, i64 %len)
54 call void asm sideeffect "blah $0", "{r0}" (i32 0)
55 %res2 = call i8 *@memchr(i8 *%res1, i32 %charext, i64 %len)