1; Test 64-bit unsigned comparisons between memory and a constant. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5; Check ordered comparisons with a constant near the low end of the unsigned 6; 16-bit range. 7define double @f1(double %a, double %b, i64 *%ptr) { 8; CHECK-LABEL: f1: 9; CHECK: clghsi 0(%r2), 2 10; CHECK-NEXT: blr %r14 11; CHECK: ldr %f0, %f2 12; CHECK: br %r14 13 %val = load i64, i64 *%ptr 14 %cond = icmp ult i64 %val, 2 15 %res = select i1 %cond, double %a, double %b 16 ret double %res 17} 18 19; Check ordered comparisons with the high end of the unsigned 16-bit range. 20define double @f2(double %a, double %b, i64 *%ptr) { 21; CHECK-LABEL: f2: 22; CHECK: clghsi 0(%r2), 65535 23; CHECK-NEXT: blr %r14 24; CHECK: ldr %f0, %f2 25; CHECK: br %r14 26 %val = load i64, i64 *%ptr 27 %cond = icmp ult i64 %val, 65535 28 %res = select i1 %cond, double %a, double %b 29 ret double %res 30} 31 32; Check the next value up, which can't use CLGHSI. 33define double @f3(double %a, double %b, i64 *%ptr) { 34; CHECK-LABEL: f3: 35; CHECK-NOT: clghsi 36; CHECK: br %r14 37 %val = load i64, i64 *%ptr 38 %cond = icmp ult i64 %val, 65536 39 %res = select i1 %cond, double %a, double %b 40 ret double %res 41} 42 43; Check equality comparisons with 32768, the lowest value for which 44; we prefer CLGHSI to CGHSI. 45define double @f4(double %a, double %b, i64 *%ptr) { 46; CHECK-LABEL: f4: 47; CHECK: clghsi 0(%r2), 32768 48; CHECK-NEXT: ber %r14 49; CHECK: ldr %f0, %f2 50; CHECK: br %r14 51 %val = load i64, i64 *%ptr 52 %cond = icmp eq i64 %val, 32768 53 %res = select i1 %cond, double %a, double %b 54 ret double %res 55} 56 57; Check equality comparisons with the high end of the unsigned 16-bit range. 58define double @f5(double %a, double %b, i64 *%ptr) { 59; CHECK-LABEL: f5: 60; CHECK: clghsi 0(%r2), 65535 61; CHECK-NEXT: ber %r14 62; CHECK: ldr %f0, %f2 63; CHECK: br %r14 64 %val = load i64, i64 *%ptr 65 %cond = icmp eq i64 %val, 65535 66 %res = select i1 %cond, double %a, double %b 67 ret double %res 68} 69 70; Check the next value up, which can't use CLGHSI. 71define double @f6(double %a, double %b, i64 *%ptr) { 72; CHECK-LABEL: f6: 73; CHECK-NOT: clghsi 74; CHECK: br %r14 75 %val = load i64, i64 *%ptr 76 %cond = icmp eq i64 %val, 65536 77 %res = select i1 %cond, double %a, double %b 78 ret double %res 79} 80 81; Check the high end of the CLGHSI range. 82define double @f7(double %a, double %b, i64 %i1, i64 *%base) { 83; CHECK-LABEL: f7: 84; CHECK: clghsi 4088(%r3), 2 85; CHECK-NEXT: blr %r14 86; CHECK: ldr %f0, %f2 87; CHECK: br %r14 88 %ptr = getelementptr i64, i64 *%base, i64 511 89 %val = load i64, i64 *%ptr 90 %cond = icmp ult i64 %val, 2 91 %res = select i1 %cond, double %a, double %b 92 ret double %res 93} 94 95; Check the next doubleword up, which needs separate address logic, 96define double @f8(double %a, double %b, i64 *%base) { 97; CHECK-LABEL: f8: 98; CHECK: aghi %r2, 4096 99; CHECK: clghsi 0(%r2), 2 100; CHECK-NEXT: blr %r14 101; CHECK: ldr %f0, %f2 102; CHECK: br %r14 103 %ptr = getelementptr i64, i64 *%base, i64 512 104 %val = load i64, i64 *%ptr 105 %cond = icmp ult i64 %val, 2 106 %res = select i1 %cond, double %a, double %b 107 ret double %res 108} 109 110; Check negative offsets, which also need separate address logic. 111define double @f9(double %a, double %b, i64 *%base) { 112; CHECK-LABEL: f9: 113; CHECK: aghi %r2, -8 114; CHECK: clghsi 0(%r2), 2 115; CHECK-NEXT: blr %r14 116; CHECK: ldr %f0, %f2 117; CHECK: br %r14 118 %ptr = getelementptr i64, i64 *%base, i64 -1 119 %val = load i64, i64 *%ptr 120 %cond = icmp ult i64 %val, 2 121 %res = select i1 %cond, double %a, double %b 122 ret double %res 123} 124 125; Check that CLGHSI does not allow indices. 126define double @f10(double %a, double %b, i64 %base, i64 %index) { 127; CHECK-LABEL: f10: 128; CHECK: agr {{%r2, %r3|%r3, %r2}} 129; CHECK: clghsi 0({{%r[23]}}), 2 130; CHECK-NEXT: blr %r14 131; CHECK: ldr %f0, %f2 132; CHECK: br %r14 133 %add = add i64 %base, %index 134 %ptr = inttoptr i64 %add to i64 * 135 %val = load i64, i64 *%ptr 136 %cond = icmp ult i64 %val, 2 137 %res = select i1 %cond, double %a, double %b 138 ret double %res 139} 140