brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.5 KiB · 42fad69 Raw
226 lines · plain
1; Test 32-bit ordered comparisons that are really between a memory halfword2; and a constant.3;4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s5 6; Check unsigned comparison near the low end of the CLHHSI range, using zero7; extension.8define double @f1(double %a, double %b, ptr %ptr) {9; CHECK-LABEL: f1:10; CHECK: clhhsi 0(%r2), 111; CHECK-NEXT: bhr %r1412; CHECK: br %r1413  %val = load i16, ptr %ptr14  %ext = zext i16 %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 CLHHSI range, using sign21; extension.22define double @f2(double %a, double %b, ptr %ptr) {23; CHECK-LABEL: f2:24; CHECK: clhhsi 0(%r2), 125; CHECK-NEXT: bhr %r1426; CHECK: br %r1427  %val = load i16, ptr %ptr28  %ext = sext i16 %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 CLHHSI range, using zero35; extension.36define double @f3(double %a, double %b, ptr %ptr) {37; CHECK-LABEL: f3:38; CHECK: clhhsi 0(%r2), 6553439; CHECK-NEXT: blr %r1440; CHECK: br %r1441  %val = load i16, ptr %ptr42  %ext = zext i16 %val to i3243  %cond = icmp ult i32 %ext, 6553444  %res = select i1 %cond, double %a, double %b45  ret double %res46}47 48; Check unsigned comparison near the high end of the CLHHSI range, using sign49; extension.50define double @f4(double %a, double %b, ptr %ptr) {51; CHECK-LABEL: f4:52; CHECK: clhhsi 0(%r2), 6553453; CHECK-NEXT: blr %r1454; CHECK: br %r1455  %val = load i16, ptr %ptr56  %ext = sext i16 %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 CLHHSI 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: clhhsi67; CHECK: br %r1468  %val = load i16, ptr %ptr69  %ext = zext i16 %val to i3270  %cond = icmp ult i32 %ext, 6553671  %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 [32768, MAX-32769] 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 CLHHSI for this range.  First check the low end of the80; range.81define double @f6(double %a, double %b, ptr %ptr) {82; CHECK-LABEL: f6:83; CHECK-NOT: clhhsi84; CHECK: br %r1485  %val = load i16, ptr %ptr86  %ext = sext i16 %val to i3287  %cond = icmp ult i32 %ext, 3276888  %res = select i1 %cond, double %a, double %b89  ret double %res90}91 92; ...and then the high end.93define double @f7(double %a, double %b, ptr %ptr) {94; CHECK-LABEL: f7:95; CHECK-NOT: clhhsi96; CHECK: br %r1497  %val = load i16, ptr %ptr98  %ext = sext i16 %val to i3299  %cond = icmp ult i32 %ext, -32769100  %res = select i1 %cond, double %a, double %b101  ret double %res102}103 104; Check signed comparison near the low end of the CLHHSI range, using zero105; extension.  This is equivalent to unsigned comparison.106define double @f8(double %a, double %b, ptr %ptr) {107; CHECK-LABEL: f8:108; CHECK: clhhsi 0(%r2), 1109; CHECK-NEXT: bhr %r14110; CHECK: br %r14111  %val = load i16, ptr %ptr112  %ext = zext i16 %val to i32113  %cond = icmp sgt i32 %ext, 1114  %res = select i1 %cond, double %a, double %b115  ret double %res116}117 118; Check signed comparison near the low end of the CLHHSI range, using sign119; extension.  This should use CHHSI instead.120define double @f9(double %a, double %b, ptr %ptr) {121; CHECK-LABEL: f9:122; CHECK: chhsi 0(%r2), 1123; CHECK-NEXT: bhr %r14124; CHECK: br %r14125  %val = load i16, ptr %ptr126  %ext = sext i16 %val to i32127  %cond = icmp sgt i32 %ext, 1128  %res = select i1 %cond, double %a, double %b129  ret double %res130}131 132; Check signed comparison near the high end of the CLHHSI range, using zero133; extension.  This is equivalent to unsigned comparison.134define double @f10(double %a, double %b, ptr %ptr) {135; CHECK-LABEL: f10:136; CHECK: clhhsi 0(%r2), 65534137; CHECK-NEXT: blr %r14138; CHECK: br %r14139  %val = load i16, ptr %ptr140  %ext = zext i16 %val to i32141  %cond = icmp slt i32 %ext, 65534142  %res = select i1 %cond, double %a, double %b143  ret double %res144}145 146; Check signed comparison near the high end of the CLHHSI range, using sign147; extension.  This should use CHHSI instead.148define double @f11(double %a, double %b, ptr %ptr) {149; CHECK-LABEL: f11:150; CHECK: chhsi 0(%r2), -2151; CHECK-NEXT: blr %r14152; CHECK: br %r14153  %val = load i16, ptr %ptr154  %ext = sext i16 %val to i32155  %cond = icmp slt i32 %ext, -2156  %res = select i1 %cond, double %a, double %b157  ret double %res158}159 160; Check signed comparison above the high end of the CLHHSI range, using zero161; extension.  The condition is always true.162define double @f12(double %a, double %b, ptr %ptr) {163; CHECK-LABEL: f12:164; CHECK-NOT: cli165; CHECK: br %r14166  %val = load i16, ptr %ptr167  %ext = zext i16 %val to i32168  %cond = icmp slt i32 %ext, 65536169  %res = select i1 %cond, double %a, double %b170  ret double %res171}172 173; Check signed comparison near the high end of the CHHSI range, using sign174; extension.175define double @f13(double %a, double %b, ptr %ptr) {176; CHECK-LABEL: f13:177; CHECK: chhsi 0(%r2), 32766178; CHECK-NEXT: blr %r14179; CHECK: br %r14180  %val = load i16, ptr %ptr181  %ext = sext i16 %val to i32182  %cond = icmp slt i32 %ext, 32766183  %res = select i1 %cond, double %a, double %b184  ret double %res185}186 187; Check signed comparison above the high end of the CHHSI range, using sign188; extension.  This condition is always true.189define double @f14(double %a, double %b, ptr %ptr) {190; CHECK-LABEL: f14:191; CHECK-NOT: chhsi192; CHECK: br %r14193  %val = load i16, ptr %ptr194  %ext = sext i16 %val to i32195  %cond = icmp slt i32 %ext, 32768196  %res = select i1 %cond, double %a, double %b197  ret double %res198}199 200; Check signed comparison near the low end of the CHHSI range, using sign201; extension.202define double @f15(double %a, double %b, ptr %ptr) {203; CHECK-LABEL: f15:204; CHECK: chhsi 0(%r2), -32767205; CHECK-NEXT: bhr %r14206; CHECK: br %r14207  %val = load i16, ptr %ptr208  %ext = sext i16 %val to i32209  %cond = icmp sgt i32 %ext, -32767210  %res = select i1 %cond, double %a, double %b211  ret double %res212}213 214; Check signed comparison below the low end of the CHHSI range, using sign215; extension.  This condition is always true.216define double @f16(double %a, double %b, ptr %ptr) {217; CHECK-LABEL: f16:218; CHECK-NOT: chhsi219; CHECK: br %r14220  %val = load i16, ptr %ptr221  %ext = sext i16 %val to i32222  %cond = icmp sgt i32 %ext, -32769223  %res = select i1 %cond, double %a, double %b224  ret double %res225}226