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