brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · 6d66bfa Raw
221 lines · plain
1; Test 32-bit ordered comparisons that are really between a memory byte2; and a constant.3;4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s5 6; Check unsigned comparison near the low end of the CLI range, using zero7; extension.8define double @f1(double %a, double %b, ptr %ptr) {9; CHECK-LABEL: f1:10; CHECK: cli 0(%r2), 111; CHECK-NEXT: bhr %r1412; CHECK: br %r1413  %val = load i8, ptr %ptr14  %ext = zext i8 %val to i3215  %cond = icmp ugt i32 %ext, 116  %res = select i1 %cond, double %a, double %b17  ret double %res18}19 20; Check unsigned comparison near the low end of the CLI range, using sign21; extension.22define double @f2(double %a, double %b, ptr %ptr) {23; CHECK-LABEL: f2:24; CHECK: cli 0(%r2), 125; CHECK-NEXT: bhr %r1426; CHECK: br %r1427  %val = load i8, ptr %ptr28  %ext = sext i8 %val to i3229  %cond = icmp ugt i32 %ext, 130  %res = select i1 %cond, double %a, double %b31  ret double %res32}33 34; Check unsigned comparison near the high end of the CLI range, using zero35; extension.36define double @f3(double %a, double %b, ptr %ptr) {37; CHECK-LABEL: f3:38; CHECK: cli 0(%r2), 25439; CHECK-NEXT: blr %r1440; CHECK: br %r1441  %val = load i8, ptr %ptr42  %ext = zext i8 %val to i3243  %cond = icmp ult i32 %ext, 25444  %res = select i1 %cond, double %a, double %b45  ret double %res46}47 48; Check unsigned comparison near the high end of the CLI range, using sign49; extension.50define double @f4(double %a, double %b, ptr %ptr) {51; CHECK-LABEL: f4:52; CHECK: cli 0(%r2), 25453; CHECK-NEXT: blr %r1454; CHECK: br %r1455  %val = load i8, ptr %ptr56  %ext = sext i8 %val to i3257  %cond = icmp ult i32 %ext, -258  %res = select i1 %cond, double %a, double %b59  ret double %res60}61 62; Check unsigned comparison above the high end of the CLI range, using zero63; extension.  The condition is always true.64define double @f5(double %a, double %b, ptr %ptr) {65; CHECK-LABEL: f5:66; CHECK-NOT: cli {{.*}}67; CHECK: br %r1468  %val = load i8, ptr %ptr69  %ext = zext i8 %val to i3270  %cond = icmp ult i32 %ext, 25671  %res = select i1 %cond, double %a, double %b72  ret double %res73}74 75; When using unsigned comparison with sign extension, equality with values76; in the range [128, MAX-129] is impossible, and ordered comparisons with77; those values are effectively sign tests.  Since such comparisons are78; unlikely to occur in practice, we don't bother optimizing the second case,79; and simply ignore CLI for this range.  First check the low end of the range.80define double @f6(double %a, double %b, ptr %ptr) {81; CHECK-LABEL: f6:82; CHECK-NOT: cli {{.*}}83; CHECK: br %r1484  %val = load i8, ptr %ptr85  %ext = sext i8 %val to i3286  %cond = icmp ult i32 %ext, 12887  %res = select i1 %cond, double %a, double %b88  ret double %res89}90 91; ...and then the high end.92define double @f7(double %a, double %b, ptr %ptr) {93; CHECK-LABEL: f7:94; CHECK-NOT: cli {{.*}}95; CHECK: br %r1496  %val = load i8, ptr %ptr97  %ext = sext i8 %val to i3298  %cond = icmp ult i32 %ext, -12999  %res = select i1 %cond, double %a, double %b100  ret double %res101}102 103; Check signed comparison near the low end of the CLI range, using zero104; extension.  This is equivalent to unsigned comparison.105define double @f8(double %a, double %b, ptr %ptr) {106; CHECK-LABEL: f8:107; CHECK: cli 0(%r2), 1108; CHECK-NEXT: bhr %r14109; CHECK: br %r14110  %val = load i8, ptr %ptr111  %ext = zext i8 %val to i32112  %cond = icmp sgt i32 %ext, 1113  %res = select i1 %cond, double %a, double %b114  ret double %res115}116 117; Check signed comparison near the low end of the CLI range, using sign118; extension.  This cannot use CLI.119define double @f9(double %a, double %b, ptr %ptr) {120; CHECK-LABEL: f9:121; CHECK-NOT: cli {{.*}}122; CHECK: br %r14123  %val = load i8, ptr %ptr124  %ext = sext i8 %val to i32125  %cond = icmp sgt i32 %ext, 1126  %res = select i1 %cond, double %a, double %b127  ret double %res128}129 130; Check signed comparison near the high end of the CLI range, using zero131; extension.  This is equivalent to unsigned comparison.132define double @f10(double %a, double %b, ptr %ptr) {133; CHECK-LABEL: f10:134; CHECK: cli 0(%r2), 254135; CHECK-NEXT: blr %r14136; CHECK: br %r14137  %val = load i8, ptr %ptr138  %ext = zext i8 %val to i32139  %cond = icmp slt i32 %ext, 254140  %res = select i1 %cond, double %a, double %b141  ret double %res142}143 144; Check signed comparison near the high end of the CLI range, using sign145; extension.  This cannot use CLI.146define double @f11(double %a, double %b, ptr %ptr) {147; CHECK-LABEL: f11:148; CHECK-NOT: cli {{.*}}149; CHECK: br %r14150  %val = load i8, ptr %ptr151  %ext = sext i8 %val to i32152  %cond = icmp slt i32 %ext, -2153  %res = select i1 %cond, double %a, double %b154  ret double %res155}156 157; Check signed comparison above the high end of the CLI range, using zero158; extension.  The condition is always true.159define double @f12(double %a, double %b, ptr %ptr) {160; CHECK-LABEL: f12:161; CHECK-NOT: cli {{.*}}162; CHECK: br %r14163  %val = load i8, ptr %ptr164  %ext = zext i8 %val to i32165  %cond = icmp slt i32 %ext, 256166  %res = select i1 %cond, double %a, double %b167  ret double %res168}169 170; Check tests for nonnegative values.171define double @f13(double %a, double %b, ptr %ptr) {172; CHECK-LABEL: f13:173; CHECK: cli 0(%r2), 128174; CHECK-NEXT: blr %r14175; CHECK: br %r14176  %val = load i8, ptr %ptr177  %ext = sext i8 %val to i32178  %cond = icmp sge i32 %ext, 0179  %res = select i1 %cond, double %a, double %b180  ret double %res181}182 183; ...and another form184define double @f14(double %a, double %b, ptr %ptr) {185; CHECK-LABEL: f14:186; CHECK: cli 0(%r2), 128187; CHECK-NEXT: blr %r14188; CHECK: br %r14189  %val = load i8, ptr %ptr190  %ext = sext i8 %val to i32191  %cond = icmp sgt i32 %ext, -1192  %res = select i1 %cond, double %a, double %b193  ret double %res194}195 196; Check tests for negative values.197define double @f15(double %a, double %b, ptr %ptr) {198; CHECK-LABEL: f15:199; CHECK: cli 0(%r2), 127200; CHECK-NEXT: bhr %r14201; CHECK: br %r14202  %val = load i8, ptr %ptr203  %ext = sext i8 %val to i32204  %cond = icmp slt i32 %ext, 0205  %res = select i1 %cond, double %a, double %b206  ret double %res207}208 209; ...and another form210define double @f16(double %a, double %b, ptr %ptr) {211; CHECK-LABEL: f16:212; CHECK: cli 0(%r2), 127213; CHECK-NEXT: bhr %r14214; CHECK: br %r14215  %val = load i8, ptr %ptr216  %ext = sext i8 %val to i32217  %cond = icmp sle i32 %ext, -1218  %res = select i1 %cond, double %a, double %b219  ret double %res220}221