1*9880d681SAndroid Build Coastguard Worker; Test all condition-code masks that are relevant for CRJ. 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 i32 @foo() 6*9880d681SAndroid Build Coastguard Worker@g1 = global i16 0 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Workerdefine void @f1(i32 %target) { 9*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1: 10*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 11*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 12*9880d681SAndroid Build Coastguard Worker; CHECK: crje %r2, {{%r[0-9]+}}, .L[[LABEL]] 13*9880d681SAndroid Build Coastguard Worker br label %loop 14*9880d681SAndroid Build Coastguard Workerloop: 15*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 16*9880d681SAndroid Build Coastguard Worker %cond = icmp eq i32 %val, %target 17*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 18*9880d681SAndroid Build Coastguard Workerexit: 19*9880d681SAndroid Build Coastguard Worker ret void 20*9880d681SAndroid Build Coastguard Worker} 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Workerdefine void @f2(i32 %target) { 23*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2: 24*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 25*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 26*9880d681SAndroid Build Coastguard Worker; CHECK: crjlh %r2, {{%r[0-9]+}}, .L[[LABEL]] 27*9880d681SAndroid Build Coastguard Worker br label %loop 28*9880d681SAndroid Build Coastguard Workerloop: 29*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 30*9880d681SAndroid Build Coastguard Worker %cond = icmp ne i32 %val, %target 31*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 32*9880d681SAndroid Build Coastguard Workerexit: 33*9880d681SAndroid Build Coastguard Worker ret void 34*9880d681SAndroid Build Coastguard Worker} 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Workerdefine void @f3(i32 %target) { 37*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3: 38*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 39*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 40*9880d681SAndroid Build Coastguard Worker; CHECK: crjle %r2, {{%r[0-9]+}}, .L[[LABEL]] 41*9880d681SAndroid Build Coastguard Worker br label %loop 42*9880d681SAndroid Build Coastguard Workerloop: 43*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 44*9880d681SAndroid Build Coastguard Worker %cond = icmp sle i32 %val, %target 45*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 46*9880d681SAndroid Build Coastguard Workerexit: 47*9880d681SAndroid Build Coastguard Worker ret void 48*9880d681SAndroid Build Coastguard Worker} 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Workerdefine void @f4(i32 %target) { 51*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f4: 52*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 53*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 54*9880d681SAndroid Build Coastguard Worker; CHECK: crjl %r2, {{%r[0-9]+}}, .L[[LABEL]] 55*9880d681SAndroid Build Coastguard Worker br label %loop 56*9880d681SAndroid Build Coastguard Workerloop: 57*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 58*9880d681SAndroid Build Coastguard Worker %cond = icmp slt i32 %val, %target 59*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 60*9880d681SAndroid Build Coastguard Workerexit: 61*9880d681SAndroid Build Coastguard Worker ret void 62*9880d681SAndroid Build Coastguard Worker} 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Workerdefine void @f5(i32 %target) { 65*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f5: 66*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 67*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 68*9880d681SAndroid Build Coastguard Worker; CHECK: crjh %r2, {{%r[0-9]+}}, .L[[LABEL]] 69*9880d681SAndroid Build Coastguard Worker br label %loop 70*9880d681SAndroid Build Coastguard Workerloop: 71*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 72*9880d681SAndroid Build Coastguard Worker %cond = icmp sgt i32 %val, %target 73*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 74*9880d681SAndroid Build Coastguard Workerexit: 75*9880d681SAndroid Build Coastguard Worker ret void 76*9880d681SAndroid Build Coastguard Worker} 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Workerdefine void @f6(i32 %target) { 79*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f6: 80*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 81*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 82*9880d681SAndroid Build Coastguard Worker; CHECK: crjhe %r2, {{%r[0-9]+}}, .L[[LABEL]] 83*9880d681SAndroid Build Coastguard Worker br label %loop 84*9880d681SAndroid Build Coastguard Workerloop: 85*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 86*9880d681SAndroid Build Coastguard Worker %cond = icmp sge i32 %val, %target 87*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 88*9880d681SAndroid Build Coastguard Workerexit: 89*9880d681SAndroid Build Coastguard Worker ret void 90*9880d681SAndroid Build Coastguard Worker} 91*9880d681SAndroid Build Coastguard Worker 92*9880d681SAndroid Build Coastguard Worker; Check that CRJ is used for checking equality with a zero-extending 93*9880d681SAndroid Build Coastguard Worker; character load. 94*9880d681SAndroid Build Coastguard Workerdefine void @f7(i8 *%targetptr) { 95*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f7: 96*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 97*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 98*9880d681SAndroid Build Coastguard Worker; CHECK: llc [[REG:%r[0-5]]], 99*9880d681SAndroid Build Coastguard Worker; CHECK: crje %r2, [[REG]], .L[[LABEL]] 100*9880d681SAndroid Build Coastguard Worker br label %loop 101*9880d681SAndroid Build Coastguard Workerloop: 102*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 103*9880d681SAndroid Build Coastguard Worker %byte = load i8 , i8 *%targetptr 104*9880d681SAndroid Build Coastguard Worker %target = zext i8 %byte to i32 105*9880d681SAndroid Build Coastguard Worker %cond = icmp eq i32 %val, %target 106*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 107*9880d681SAndroid Build Coastguard Workerexit: 108*9880d681SAndroid Build Coastguard Worker ret void 109*9880d681SAndroid Build Coastguard Worker} 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker; ...and zero-extending i16 loads. 112*9880d681SAndroid Build Coastguard Workerdefine void @f8(i16 *%targetptr) { 113*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f8: 114*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 115*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 116*9880d681SAndroid Build Coastguard Worker; CHECK: llh [[REG:%r[0-5]]], 117*9880d681SAndroid Build Coastguard Worker; CHECK: crje %r2, [[REG]], .L[[LABEL]] 118*9880d681SAndroid Build Coastguard Worker br label %loop 119*9880d681SAndroid Build Coastguard Workerloop: 120*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 121*9880d681SAndroid Build Coastguard Worker %half = load i16 , i16 *%targetptr 122*9880d681SAndroid Build Coastguard Worker %target = zext i16 %half to i32 123*9880d681SAndroid Build Coastguard Worker %cond = icmp eq i32 %val, %target 124*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 125*9880d681SAndroid Build Coastguard Workerexit: 126*9880d681SAndroid Build Coastguard Worker ret void 127*9880d681SAndroid Build Coastguard Worker} 128*9880d681SAndroid Build Coastguard Worker 129*9880d681SAndroid Build Coastguard Worker; ...unless the address is a global. 130*9880d681SAndroid Build Coastguard Workerdefine void @f9(i16 *%targetptr) { 131*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f9: 132*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 133*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 134*9880d681SAndroid Build Coastguard Worker; CHECK: clhrl %r2, g1 135*9880d681SAndroid Build Coastguard Worker; CHECK: je .L[[LABEL]] 136*9880d681SAndroid Build Coastguard Worker br label %loop 137*9880d681SAndroid Build Coastguard Workerloop: 138*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 139*9880d681SAndroid Build Coastguard Worker %half = load i16 , i16 *@g1 140*9880d681SAndroid Build Coastguard Worker %target = zext i16 %half to i32 141*9880d681SAndroid Build Coastguard Worker %cond = icmp eq i32 %val, %target 142*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 143*9880d681SAndroid Build Coastguard Workerexit: 144*9880d681SAndroid Build Coastguard Worker ret void 145*9880d681SAndroid Build Coastguard Worker} 146*9880d681SAndroid Build Coastguard Worker 147*9880d681SAndroid Build Coastguard Worker; Check that CRJ is used for checking order between two zero-extending 148*9880d681SAndroid Build Coastguard Worker; byte loads, even if the original comparison was unsigned. 149*9880d681SAndroid Build Coastguard Workerdefine void @f10(i8 *%targetptr1) { 150*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f10: 151*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 152*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 153*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: llc [[REG1:%r[0-5]]], 0( 154*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: llc [[REG2:%r[0-5]]], 1( 155*9880d681SAndroid Build Coastguard Worker; CHECK: crjl [[REG1]], [[REG2]], .L[[LABEL]] 156*9880d681SAndroid Build Coastguard Worker br label %loop 157*9880d681SAndroid Build Coastguard Workerloop: 158*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 159*9880d681SAndroid Build Coastguard Worker %targetptr2 = getelementptr i8, i8 *%targetptr1, i64 1 160*9880d681SAndroid Build Coastguard Worker %byte1 = load i8 , i8 *%targetptr1 161*9880d681SAndroid Build Coastguard Worker %byte2 = load i8 , i8 *%targetptr2 162*9880d681SAndroid Build Coastguard Worker %ext1 = zext i8 %byte1 to i32 163*9880d681SAndroid Build Coastguard Worker %ext2 = zext i8 %byte2 to i32 164*9880d681SAndroid Build Coastguard Worker %cond = icmp ult i32 %ext1, %ext2 165*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 166*9880d681SAndroid Build Coastguard Workerexit: 167*9880d681SAndroid Build Coastguard Worker ret void 168*9880d681SAndroid Build Coastguard Worker} 169*9880d681SAndroid Build Coastguard Worker 170*9880d681SAndroid Build Coastguard Worker; ...likewise halfword loads. 171*9880d681SAndroid Build Coastguard Workerdefine void @f11(i16 *%targetptr1) { 172*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f11: 173*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 174*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL:.*]]: 175*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: llh [[REG1:%r[0-5]]], 0( 176*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: llh [[REG2:%r[0-5]]], 2( 177*9880d681SAndroid Build Coastguard Worker; CHECK: crjl [[REG1]], [[REG2]], .L[[LABEL]] 178*9880d681SAndroid Build Coastguard Worker br label %loop 179*9880d681SAndroid Build Coastguard Workerloop: 180*9880d681SAndroid Build Coastguard Worker %val = call i32 @foo() 181*9880d681SAndroid Build Coastguard Worker %targetptr2 = getelementptr i16, i16 *%targetptr1, i64 1 182*9880d681SAndroid Build Coastguard Worker %half1 = load i16 , i16 *%targetptr1 183*9880d681SAndroid Build Coastguard Worker %half2 = load i16 , i16 *%targetptr2 184*9880d681SAndroid Build Coastguard Worker %ext1 = zext i16 %half1 to i32 185*9880d681SAndroid Build Coastguard Worker %ext2 = zext i16 %half2 to i32 186*9880d681SAndroid Build Coastguard Worker %cond = icmp ult i32 %ext1, %ext2 187*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %loop, label %exit 188*9880d681SAndroid Build Coastguard Workerexit: 189*9880d681SAndroid Build Coastguard Worker ret void 190*9880d681SAndroid Build Coastguard Worker} 191