1 ; Test memchr using SRST, with the correct prototype. 2 ; 3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -no-integrated-as | FileCheck %s 4 5 declare i8 *@memchr(i8 *%src, i32 %char, i64 %len) 6 7 ; Test a simple forwarded call. 8 define i8 *@f1(i64 %len, i8 *%src, i32 %char) { 9 ; CHECK-LABEL: f1: 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]] 15 ; CHECK: jl {{\.L.*}} 16 ; CHECK: lghi %r2, 0 17 ; CHECK: br %r14 18 %res = call i8 *@memchr(i8 *%src, i32 %char, i64 %len) 19 ret i8 *%res 20 } 21 22 ; Test a doubled call with no use of %r0 in between. There should be a 23 ; single load of %r0. 24 define i8 *@f2(i8 *%src, i8 *%charptr, i64 %len) { 25 ; CHECK-LABEL: f2: 26 ; CHECK: llc %r0, 0(%r3) 27 ; CHECK-NOT: %r0 28 ; CHECK: srst [[RES1:%r[1-5]]], %r2 29 ; CHECK-NOT: %r0 30 ; CHECK: srst %r2, [[RES1]] 31 ; CHECK: br %r14 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) 36 ret i8 *%res2 37 } 38 39 ; Test a doubled call with a use of %r0 in between. %r0 must be loaded 40 ; for each loop. 41 define i8 *@f3(i8 *%src, i8 *%charptr, i64 %len) { 42 ; CHECK-LABEL: f3: 43 ; CHECK: llc [[CHAR:%r[1-5]]], 0(%r3) 44 ; CHECK: lr %r0, [[CHAR]] 45 ; CHECK: srst [[RES1:%r[1-5]]], %r2 46 ; CHECK: lhi %r0, 0 47 ; CHECK: blah %r0 48 ; CHECK: lr %r0, [[CHAR]] 49 ; CHECK: srst %r2, [[RES1]] 50 ; CHECK: br %r14 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) 56 ret i8 *%res2 57 } 58