1*9880d681SAndroid Build Coastguard Worker; Test strcmp using CLST, i32 version. 2*9880d681SAndroid Build Coastguard Worker; 3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workerdeclare signext i32 @strcmp(i8 *%src1, i8 *%src2) 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker; Check a case where the result is used as an integer. 8*9880d681SAndroid Build Coastguard Workerdefine i32 @f1(i8 *%src1, i8 *%src2) { 9*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1: 10*9880d681SAndroid Build Coastguard Worker; CHECK: lhi %r0, 0 11*9880d681SAndroid Build Coastguard Worker; CHECK: [[LABEL:\.[^:]*]]: 12*9880d681SAndroid Build Coastguard Worker; CHECK: clst %r2, %r3 13*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: jo [[LABEL]] 14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: BB#{{[0-9]+}} 15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ipm [[REG:%r[0-5]]] 16*9880d681SAndroid Build Coastguard Worker; CHECK: srl [[REG]], 28 17*9880d681SAndroid Build Coastguard Worker; CHECK: rll %r2, [[REG]], 31 18*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 19*9880d681SAndroid Build Coastguard Worker %res = call i32 @strcmp(i8 *%src1, i8 *%src2) 20*9880d681SAndroid Build Coastguard Worker ret i32 %res 21*9880d681SAndroid Build Coastguard Worker} 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker; Check a case where the result is tested for equality. 24*9880d681SAndroid Build Coastguard Workerdefine void @f2(i8 *%src1, i8 *%src2, i32 *%dest) { 25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2: 26*9880d681SAndroid Build Coastguard Worker; CHECK: lhi %r0, 0 27*9880d681SAndroid Build Coastguard Worker; CHECK: [[LABEL:\.[^:]*]]: 28*9880d681SAndroid Build Coastguard Worker; CHECK: clst %r2, %r3 29*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: jo [[LABEL]] 30*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: BB#{{[0-9]+}} 31*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ber %r14 32*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 33*9880d681SAndroid Build Coastguard Worker %res = call i32 @strcmp(i8 *%src1, i8 *%src2) 34*9880d681SAndroid Build Coastguard Worker %cmp = icmp eq i32 %res, 0 35*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %exit, label %store 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Workerstore: 38*9880d681SAndroid Build Coastguard Worker store i32 0, i32 *%dest 39*9880d681SAndroid Build Coastguard Worker br label %exit 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Workerexit: 42*9880d681SAndroid Build Coastguard Worker ret void 43*9880d681SAndroid Build Coastguard Worker} 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker; Test a case where the result is used both as an integer and for 46*9880d681SAndroid Build Coastguard Worker; branching. 47*9880d681SAndroid Build Coastguard Workerdefine i32 @f3(i8 *%src1, i8 *%src2, i32 *%dest) { 48*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3: 49*9880d681SAndroid Build Coastguard Worker; CHECK: lhi %r0, 0 50*9880d681SAndroid Build Coastguard Worker; CHECK: [[LABEL:\.[^:]*]]: 51*9880d681SAndroid Build Coastguard Worker; CHECK: clst %r2, %r3 52*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: jo [[LABEL]] 53*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: BB#{{[0-9]+}} 54*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ipm [[REG:%r[0-5]]] 55*9880d681SAndroid Build Coastguard Worker; CHECK: srl [[REG]], 28 56*9880d681SAndroid Build Coastguard Worker; CHECK: rll %r2, [[REG]], 31 57*9880d681SAndroid Build Coastguard Worker; CHECK: blr %r14 58*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14 59*9880d681SAndroid Build Coastguard Workerentry: 60*9880d681SAndroid Build Coastguard Worker %res = call i32 @strcmp(i8 *%src1, i8 *%src2) 61*9880d681SAndroid Build Coastguard Worker %cmp = icmp slt i32 %res, 0 62*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %exit, label %store 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Workerstore: 65*9880d681SAndroid Build Coastguard Worker store i32 0, i32 *%dest 66*9880d681SAndroid Build Coastguard Worker br label %exit 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerexit: 69*9880d681SAndroid Build Coastguard Worker ret i32 %res 70*9880d681SAndroid Build Coastguard Worker} 71