1; Test 64-bit floating-point comparison. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5declare double @foo() 6 7; Check comparison with registers. 8define i64 @f1(i64 %a, i64 %b, double %f1, double %f2) { 9; CHECK-LABEL: f1: 10; CHECK: cdbr %f0, %f2 11; CHECK-NEXT: je 12; CHECK: lgr %r2, %r3 13; CHECK: br %r14 14 %cond = fcmp oeq double %f1, %f2 15 %res = select i1 %cond, i64 %a, i64 %b 16 ret i64 %res 17} 18 19; Check the low end of the CDB range. 20define i64 @f2(i64 %a, i64 %b, double %f1, double *%ptr) { 21; CHECK-LABEL: f2: 22; CHECK: cdb %f0, 0(%r4) 23; CHECK-NEXT: je 24; CHECK: lgr %r2, %r3 25; CHECK: br %r14 26 %f2 = load double *%ptr 27 %cond = fcmp oeq double %f1, %f2 28 %res = select i1 %cond, i64 %a, i64 %b 29 ret i64 %res 30} 31 32; Check the high end of the aligned CDB range. 33define i64 @f3(i64 %a, i64 %b, double %f1, double *%base) { 34; CHECK-LABEL: f3: 35; CHECK: cdb %f0, 4088(%r4) 36; CHECK-NEXT: je 37; CHECK: lgr %r2, %r3 38; CHECK: br %r14 39 %ptr = getelementptr double *%base, i64 511 40 %f2 = load double *%ptr 41 %cond = fcmp oeq double %f1, %f2 42 %res = select i1 %cond, i64 %a, i64 %b 43 ret i64 %res 44} 45 46; Check the next doubleword up, which needs separate address logic. 47; Other sequences besides this one would be OK. 48define i64 @f4(i64 %a, i64 %b, double %f1, double *%base) { 49; CHECK-LABEL: f4: 50; CHECK: aghi %r4, 4096 51; CHECK: cdb %f0, 0(%r4) 52; CHECK-NEXT: je 53; CHECK: lgr %r2, %r3 54; CHECK: br %r14 55 %ptr = getelementptr double *%base, i64 512 56 %f2 = load double *%ptr 57 %cond = fcmp oeq double %f1, %f2 58 %res = select i1 %cond, i64 %a, i64 %b 59 ret i64 %res 60} 61 62; Check negative displacements, which also need separate address logic. 63define i64 @f5(i64 %a, i64 %b, double %f1, double *%base) { 64; CHECK-LABEL: f5: 65; CHECK: aghi %r4, -8 66; CHECK: cdb %f0, 0(%r4) 67; CHECK-NEXT: je 68; CHECK: lgr %r2, %r3 69; CHECK: br %r14 70 %ptr = getelementptr double *%base, i64 -1 71 %f2 = load double *%ptr 72 %cond = fcmp oeq double %f1, %f2 73 %res = select i1 %cond, i64 %a, i64 %b 74 ret i64 %res 75} 76 77; Check that CDB allows indices. 78define i64 @f6(i64 %a, i64 %b, double %f1, double *%base, i64 %index) { 79; CHECK-LABEL: f6: 80; CHECK: sllg %r1, %r5, 3 81; CHECK: cdb %f0, 800(%r1,%r4) 82; CHECK-NEXT: je 83; CHECK: lgr %r2, %r3 84; CHECK: br %r14 85 %ptr1 = getelementptr double *%base, i64 %index 86 %ptr2 = getelementptr double *%ptr1, i64 100 87 %f2 = load double *%ptr2 88 %cond = fcmp oeq double %f1, %f2 89 %res = select i1 %cond, i64 %a, i64 %b 90 ret i64 %res 91} 92 93; Check that comparisons of spilled values can use CDB rather than CDBR. 94define double @f7(double *%ptr0) { 95; CHECK-LABEL: f7: 96; CHECK: brasl %r14, foo@PLT 97; CHECK: cdb {{%f[0-9]+}}, 160(%r15) 98; CHECK: br %r14 99 %ptr1 = getelementptr double *%ptr0, i64 2 100 %ptr2 = getelementptr double *%ptr0, i64 4 101 %ptr3 = getelementptr double *%ptr0, i64 6 102 %ptr4 = getelementptr double *%ptr0, i64 8 103 %ptr5 = getelementptr double *%ptr0, i64 10 104 %ptr6 = getelementptr double *%ptr0, i64 12 105 %ptr7 = getelementptr double *%ptr0, i64 14 106 %ptr8 = getelementptr double *%ptr0, i64 16 107 %ptr9 = getelementptr double *%ptr0, i64 18 108 %ptr10 = getelementptr double *%ptr0, i64 20 109 110 %val0 = load double *%ptr0 111 %val1 = load double *%ptr1 112 %val2 = load double *%ptr2 113 %val3 = load double *%ptr3 114 %val4 = load double *%ptr4 115 %val5 = load double *%ptr5 116 %val6 = load double *%ptr6 117 %val7 = load double *%ptr7 118 %val8 = load double *%ptr8 119 %val9 = load double *%ptr9 120 %val10 = load double *%ptr10 121 122 %ret = call double @foo() 123 124 %cmp0 = fcmp olt double %ret, %val0 125 %cmp1 = fcmp olt double %ret, %val1 126 %cmp2 = fcmp olt double %ret, %val2 127 %cmp3 = fcmp olt double %ret, %val3 128 %cmp4 = fcmp olt double %ret, %val4 129 %cmp5 = fcmp olt double %ret, %val5 130 %cmp6 = fcmp olt double %ret, %val6 131 %cmp7 = fcmp olt double %ret, %val7 132 %cmp8 = fcmp olt double %ret, %val8 133 %cmp9 = fcmp olt double %ret, %val9 134 %cmp10 = fcmp olt double %ret, %val10 135 136 %sel0 = select i1 %cmp0, double %ret, double 0.0 137 %sel1 = select i1 %cmp1, double %sel0, double 1.0 138 %sel2 = select i1 %cmp2, double %sel1, double 2.0 139 %sel3 = select i1 %cmp3, double %sel2, double 3.0 140 %sel4 = select i1 %cmp4, double %sel3, double 4.0 141 %sel5 = select i1 %cmp5, double %sel4, double 5.0 142 %sel6 = select i1 %cmp6, double %sel5, double 6.0 143 %sel7 = select i1 %cmp7, double %sel6, double 7.0 144 %sel8 = select i1 %cmp8, double %sel7, double 8.0 145 %sel9 = select i1 %cmp9, double %sel8, double 9.0 146 %sel10 = select i1 %cmp10, double %sel9, double 10.0 147 148 ret double %sel10 149} 150 151; Check comparison with zero. 152define i64 @f8(i64 %a, i64 %b, double %f) { 153; CHECK-LABEL: f8: 154; CHECK: ltdbr %f0, %f0 155; CHECK-NEXT: je 156; CHECK: lgr %r2, %r3 157; CHECK: br %r14 158 %cond = fcmp oeq double %f, 0.0 159 %res = select i1 %cond, i64 %a, i64 %b 160 ret i64 %res 161} 162