242 lines · plain
1; Test 8-bit unsigned comparisons between memory and constants.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s4 5; Check ordered comparisons near the low end of the unsigned 8-bit range.6define double @f1(double %a, double %b, ptr %ptr) {7; CHECK-LABEL: f1:8; CHECK: cli 0(%r2), 19; CHECK-NEXT: bhr %r1410; CHECK: br %r1411 %val = load i8, ptr %ptr12 %cond = icmp ugt i8 %val, 113 %res = select i1 %cond, double %a, double %b14 ret double %res15}16 17; Check ordered comparisons near the high end of the unsigned 8-bit range.18define double @f2(double %a, double %b, ptr %ptr) {19; CHECK-LABEL: f2:20; CHECK: cli 0(%r2), 25421; CHECK-NEXT: blr %r1422; CHECK: br %r1423 %val = load i8, ptr %ptr24 %cond = icmp ult i8 %val, 25425 %res = select i1 %cond, double %a, double %b26 ret double %res27}28 29; Check tests for negative bytes.30define double @f3(double %a, double %b, ptr %ptr) {31; CHECK-LABEL: f3:32; CHECK: cli 0(%r2), 12733; CHECK-NEXT: bhr %r1434; CHECK: br %r1435 %val = load i8, ptr %ptr36 %cond = icmp slt i8 %val, 037 %res = select i1 %cond, double %a, double %b38 ret double %res39}40 41; ...and an alternative form.42define double @f4(double %a, double %b, ptr %ptr) {43; CHECK-LABEL: f4:44; CHECK: cli 0(%r2), 12745; CHECK-NEXT: bhr %r1446; CHECK: br %r1447 %val = load i8, ptr %ptr48 %cond = icmp sle i8 %val, -149 %res = select i1 %cond, double %a, double %b50 ret double %res51}52 53; Check tests for non-negative bytes.54define double @f5(double %a, double %b, ptr %ptr) {55; CHECK-LABEL: f5:56; CHECK: cli 0(%r2), 12857; CHECK-NEXT: blr %r1458; CHECK: br %r1459 %val = load i8, ptr %ptr60 %cond = icmp sge i8 %val, 061 %res = select i1 %cond, double %a, double %b62 ret double %res63}64 65; ...and an alternative form.66define double @f6(double %a, double %b, ptr %ptr) {67; CHECK-LABEL: f6:68; CHECK: cli 0(%r2), 12869; CHECK-NEXT: blr %r1470; CHECK: br %r1471 %val = load i8, ptr %ptr72 %cond = icmp sgt i8 %val, -173 %res = select i1 %cond, double %a, double %b74 ret double %res75}76 77; Check equality comparisons at the low end of the signed 8-bit range.78define double @f7(double %a, double %b, ptr %ptr) {79; CHECK-LABEL: f7:80; CHECK: cli 0(%r2), 12881; CHECK-NEXT: ber %r1482; CHECK: br %r1483 %val = load i8, ptr %ptr84 %cond = icmp eq i8 %val, -12885 %res = select i1 %cond, double %a, double %b86 ret double %res87}88 89; Check equality comparisons at the low end of the unsigned 8-bit range.90define double @f8(double %a, double %b, ptr %ptr) {91; CHECK-LABEL: f8:92; CHECK: cli 0(%r2), 093; CHECK-NEXT: ber %r1494; CHECK: br %r1495 %val = load i8, ptr %ptr96 %cond = icmp eq i8 %val, 097 %res = select i1 %cond, double %a, double %b98 ret double %res99}100 101; Check equality comparisons at the high end of the signed 8-bit range.102define double @f9(double %a, double %b, ptr %ptr) {103; CHECK-LABEL: f9:104; CHECK: cli 0(%r2), 127105; CHECK-NEXT: ber %r14106; CHECK: br %r14107 %val = load i8, ptr %ptr108 %cond = icmp eq i8 %val, 127109 %res = select i1 %cond, double %a, double %b110 ret double %res111}112 113; Check equality comparisons at the high end of the unsigned 8-bit range.114define double @f10(double %a, double %b, ptr %ptr) {115; CHECK-LABEL: f10:116; CHECK: cli 0(%r2), 255117; CHECK-NEXT: ber %r14118; CHECK: br %r14119 %val = load i8, ptr %ptr120 %cond = icmp eq i8 %val, 255121 %res = select i1 %cond, double %a, double %b122 ret double %res123}124 125; Check the high end of the CLI range.126define double @f11(double %a, double %b, ptr %src) {127; CHECK-LABEL: f11:128; CHECK: cli 4095(%r2), 127129; CHECK: br %r14130 %ptr = getelementptr i8, ptr %src, i64 4095131 %val = load i8, ptr %ptr132 %cond = icmp ult i8 %val, 127133 %res = select i1 %cond, double %a, double %b134 ret double %res135}136 137; Check the next byte up, which should use CLIY instead of CLI.138define double @f12(double %a, double %b, ptr %src) {139; CHECK-LABEL: f12:140; CHECK: cliy 4096(%r2), 127141; CHECK: br %r14142 %ptr = getelementptr i8, ptr %src, i64 4096143 %val = load i8, ptr %ptr144 %cond = icmp ult i8 %val, 127145 %res = select i1 %cond, double %a, double %b146 ret double %res147}148 149; Check the high end of the CLIY range.150define double @f13(double %a, double %b, ptr %src) {151; CHECK-LABEL: f13:152; CHECK: cliy 524287(%r2), 127153; CHECK: br %r14154 %ptr = getelementptr i8, ptr %src, i64 524287155 %val = load i8, ptr %ptr156 %cond = icmp ult i8 %val, 127157 %res = select i1 %cond, double %a, double %b158 ret double %res159}160 161; Check the next byte up, which needs separate address logic.162; Other sequences besides this one would be OK.163define double @f14(double %a, double %b, ptr %src) {164; CHECK-LABEL: f14:165; CHECK: agfi %r2, 524288166; CHECK: cli 0(%r2), 127167; CHECK: br %r14168 %ptr = getelementptr i8, ptr %src, i64 524288169 %val = load i8, ptr %ptr170 %cond = icmp ult i8 %val, 127171 %res = select i1 %cond, double %a, double %b172 ret double %res173}174 175; Check the high end of the negative CLIY range.176define double @f15(double %a, double %b, ptr %src) {177; CHECK-LABEL: f15:178; CHECK: cliy -1(%r2), 127179; CHECK: br %r14180 %ptr = getelementptr i8, ptr %src, i64 -1181 %val = load i8, ptr %ptr182 %cond = icmp ult i8 %val, 127183 %res = select i1 %cond, double %a, double %b184 ret double %res185}186 187; Check the low end of the CLIY range.188define double @f16(double %a, double %b, ptr %src) {189; CHECK-LABEL: f16:190; CHECK: cliy -524288(%r2), 127191; CHECK: br %r14192 %ptr = getelementptr i8, ptr %src, i64 -524288193 %val = load i8, ptr %ptr194 %cond = icmp ult i8 %val, 127195 %res = select i1 %cond, double %a, double %b196 ret double %res197}198 199; Check the next byte down, which needs separate address logic.200; Other sequences besides this one would be OK.201define double @f17(double %a, double %b, ptr %src) {202; CHECK-LABEL: f17:203; CHECK: agfi %r2, -524289204; CHECK: cli 0(%r2), 127205; CHECK: br %r14206 %ptr = getelementptr i8, ptr %src, i64 -524289207 %val = load i8, ptr %ptr208 %cond = icmp ult i8 %val, 127209 %res = select i1 %cond, double %a, double %b210 ret double %res211}212 213; Check that CLI does not allow an index214define double @f18(double %a, double %b, i64 %base, i64 %index) {215; CHECK-LABEL: f18:216; CHECK: agr %r2, %r3217; CHECK: cli 4095(%r2), 127218; CHECK: br %r14219 %add1 = add i64 %base, %index220 %add2 = add i64 %add1, 4095221 %ptr = inttoptr i64 %add2 to ptr222 %val = load i8, ptr %ptr223 %cond = icmp ult i8 %val, 127224 %res = select i1 %cond, double %a, double %b225 ret double %res226}227 228; Check that CLIY does not allow an index229define double @f19(double %a, double %b, i64 %base, i64 %index) {230; CHECK-LABEL: f19:231; CHECK: agr %r2, %r3232; CHECK: cliy 4096(%r2), 127233; CHECK: br %r14234 %add1 = add i64 %base, %index235 %add2 = add i64 %add1, 4096236 %ptr = inttoptr i64 %add2 to ptr237 %val = load i8, ptr %ptr238 %cond = icmp ult i8 %val, 127239 %res = select i1 %cond, double %a, double %b240 ret double %res241}242