Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 1 | ; Test 32-bit ordered comparisons that are really between a memory byte |
| 2 | ; and a constant. |
| 3 | ; |
| 4 | ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s |
| 5 | |
| 6 | ; Check unsigned comparison near the low end of the CLI range, using zero |
| 7 | ; extension. |
| 8 | define double @f1(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 9 | ; CHECK-LABEL: f1: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 10 | ; CHECK: cli 0(%r2), 1 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 11 | ; CHECK-NEXT: jh |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 12 | ; CHECK: br %r14 |
| 13 | %val = load i8 *%ptr |
| 14 | %ext = zext i8 %val to i32 |
| 15 | %cond = icmp ugt i32 %ext, 1 |
| 16 | %res = select i1 %cond, double %a, double %b |
| 17 | ret double %res |
| 18 | } |
| 19 | |
| 20 | ; Check unsigned comparison near the low end of the CLI range, using sign |
| 21 | ; extension. |
| 22 | define double @f2(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 23 | ; CHECK-LABEL: f2: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 24 | ; CHECK: cli 0(%r2), 1 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 25 | ; CHECK-NEXT: jh |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 26 | ; CHECK: br %r14 |
| 27 | %val = load i8 *%ptr |
| 28 | %ext = sext i8 %val to i32 |
| 29 | %cond = icmp ugt i32 %ext, 1 |
| 30 | %res = select i1 %cond, double %a, double %b |
| 31 | ret double %res |
| 32 | } |
| 33 | |
| 34 | ; Check unsigned comparison near the high end of the CLI range, using zero |
| 35 | ; extension. |
| 36 | define double @f3(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 37 | ; CHECK-LABEL: f3: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 38 | ; CHECK: cli 0(%r2), 254 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 39 | ; CHECK-NEXT: jl |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 40 | ; CHECK: br %r14 |
| 41 | %val = load i8 *%ptr |
| 42 | %ext = zext i8 %val to i32 |
| 43 | %cond = icmp ult i32 %ext, 254 |
| 44 | %res = select i1 %cond, double %a, double %b |
| 45 | ret double %res |
| 46 | } |
| 47 | |
| 48 | ; Check unsigned comparison near the high end of the CLI range, using sign |
| 49 | ; extension. |
| 50 | define double @f4(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 51 | ; CHECK-LABEL: f4: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 52 | ; CHECK: cli 0(%r2), 254 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 53 | ; CHECK-NEXT: jl |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 54 | ; CHECK: br %r14 |
| 55 | %val = load i8 *%ptr |
| 56 | %ext = sext i8 %val to i32 |
| 57 | %cond = icmp ult i32 %ext, -2 |
| 58 | %res = select i1 %cond, double %a, double %b |
| 59 | ret double %res |
| 60 | } |
| 61 | |
| 62 | ; Check unsigned comparison above the high end of the CLI range, using zero |
| 63 | ; extension. The condition is always true. |
| 64 | define double @f5(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 65 | ; CHECK-LABEL: f5: |
Richard Sandiford | 93183ee | 2013-09-18 09:56:40 +0000 | [diff] [blame] | 66 | ; CHECK-NOT: cli {{.*}} |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 67 | ; CHECK: br %r14 |
| 68 | %val = load i8 *%ptr |
| 69 | %ext = zext i8 %val to i32 |
| 70 | %cond = icmp ult i32 %ext, 256 |
| 71 | %res = select i1 %cond, double %a, double %b |
| 72 | ret double %res |
| 73 | } |
| 74 | |
| 75 | ; When using unsigned comparison with sign extension, equality with values |
| 76 | ; in the range [128, MAX-129] is impossible, and ordered comparisons with |
| 77 | ; those values are effectively sign tests. Since such comparisons are |
| 78 | ; 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. |
| 80 | define double @f6(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 81 | ; CHECK-LABEL: f6: |
Richard Sandiford | 93183ee | 2013-09-18 09:56:40 +0000 | [diff] [blame] | 82 | ; CHECK-NOT: cli {{.*}} |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 83 | ; CHECK: br %r14 |
| 84 | %val = load i8 *%ptr |
| 85 | %ext = sext i8 %val to i32 |
| 86 | %cond = icmp ult i32 %ext, 128 |
| 87 | %res = select i1 %cond, double %a, double %b |
| 88 | ret double %res |
| 89 | } |
| 90 | |
| 91 | ; ...and then the high end. |
| 92 | define double @f7(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 93 | ; CHECK-LABEL: f7: |
Richard Sandiford | 93183ee | 2013-09-18 09:56:40 +0000 | [diff] [blame] | 94 | ; CHECK-NOT: cli {{.*}} |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 95 | ; CHECK: br %r14 |
| 96 | %val = load i8 *%ptr |
| 97 | %ext = sext i8 %val to i32 |
| 98 | %cond = icmp ult i32 %ext, -129 |
| 99 | %res = select i1 %cond, double %a, double %b |
| 100 | ret double %res |
| 101 | } |
| 102 | |
| 103 | ; Check signed comparison near the low end of the CLI range, using zero |
| 104 | ; extension. This is equivalent to unsigned comparison. |
| 105 | define double @f8(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 106 | ; CHECK-LABEL: f8: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 107 | ; CHECK: cli 0(%r2), 1 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 108 | ; CHECK-NEXT: jh |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 109 | ; CHECK: br %r14 |
| 110 | %val = load i8 *%ptr |
| 111 | %ext = zext i8 %val to i32 |
| 112 | %cond = icmp sgt i32 %ext, 1 |
| 113 | %res = select i1 %cond, double %a, double %b |
| 114 | ret double %res |
| 115 | } |
| 116 | |
| 117 | ; Check signed comparison near the low end of the CLI range, using sign |
| 118 | ; extension. This cannot use CLI. |
| 119 | define double @f9(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 120 | ; CHECK-LABEL: f9: |
Richard Sandiford | 93183ee | 2013-09-18 09:56:40 +0000 | [diff] [blame] | 121 | ; CHECK-NOT: cli {{.*}} |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 122 | ; CHECK: br %r14 |
| 123 | %val = load i8 *%ptr |
| 124 | %ext = sext i8 %val to i32 |
| 125 | %cond = icmp sgt i32 %ext, 1 |
| 126 | %res = select i1 %cond, double %a, double %b |
| 127 | ret double %res |
| 128 | } |
| 129 | |
| 130 | ; Check signed comparison near the high end of the CLI range, using zero |
| 131 | ; extension. This is equivalent to unsigned comparison. |
| 132 | define double @f10(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 133 | ; CHECK-LABEL: f10: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 134 | ; CHECK: cli 0(%r2), 254 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 135 | ; CHECK-NEXT: jl |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 136 | ; CHECK: br %r14 |
| 137 | %val = load i8 *%ptr |
| 138 | %ext = zext i8 %val to i32 |
| 139 | %cond = icmp slt i32 %ext, 254 |
| 140 | %res = select i1 %cond, double %a, double %b |
| 141 | ret double %res |
| 142 | } |
| 143 | |
| 144 | ; Check signed comparison near the high end of the CLI range, using sign |
| 145 | ; extension. This cannot use CLI. |
| 146 | define double @f11(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 147 | ; CHECK-LABEL: f11: |
Richard Sandiford | 93183ee | 2013-09-18 09:56:40 +0000 | [diff] [blame] | 148 | ; CHECK-NOT: cli {{.*}} |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 149 | ; CHECK: br %r14 |
| 150 | %val = load i8 *%ptr |
| 151 | %ext = sext i8 %val to i32 |
| 152 | %cond = icmp slt i32 %ext, -2 |
| 153 | %res = select i1 %cond, double %a, double %b |
| 154 | ret double %res |
| 155 | } |
| 156 | |
| 157 | ; Check signed comparison above the high end of the CLI range, using zero |
| 158 | ; extension. The condition is always true. |
| 159 | define double @f12(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 160 | ; CHECK-LABEL: f12: |
Richard Sandiford | 93183ee | 2013-09-18 09:56:40 +0000 | [diff] [blame] | 161 | ; CHECK-NOT: cli {{.*}} |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 162 | ; CHECK: br %r14 |
| 163 | %val = load i8 *%ptr |
| 164 | %ext = zext i8 %val to i32 |
| 165 | %cond = icmp slt i32 %ext, 256 |
| 166 | %res = select i1 %cond, double %a, double %b |
| 167 | ret double %res |
| 168 | } |
| 169 | |
| 170 | ; Check tests for nonnegative values. |
| 171 | define double @f13(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 172 | ; CHECK-LABEL: f13: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 173 | ; CHECK: cli 0(%r2), 128 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 174 | ; CHECK-NEXT: jl |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 175 | ; CHECK: br %r14 |
| 176 | %val = load i8 *%ptr |
| 177 | %ext = sext i8 %val to i32 |
| 178 | %cond = icmp sge i32 %ext, 0 |
| 179 | %res = select i1 %cond, double %a, double %b |
| 180 | ret double %res |
| 181 | } |
| 182 | |
| 183 | ; ...and another form |
| 184 | define double @f14(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 185 | ; CHECK-LABEL: f14: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 186 | ; CHECK: cli 0(%r2), 128 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 187 | ; CHECK-NEXT: jl |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 188 | ; CHECK: br %r14 |
| 189 | %val = load i8 *%ptr |
| 190 | %ext = sext i8 %val to i32 |
| 191 | %cond = icmp sgt i32 %ext, -1 |
| 192 | %res = select i1 %cond, double %a, double %b |
| 193 | ret double %res |
| 194 | } |
| 195 | |
| 196 | ; Check tests for negative values. |
| 197 | define double @f15(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 198 | ; CHECK-LABEL: f15: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 199 | ; CHECK: cli 0(%r2), 127 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 200 | ; CHECK-NEXT: jh |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 201 | ; CHECK: br %r14 |
| 202 | %val = load i8 *%ptr |
| 203 | %ext = sext i8 %val to i32 |
| 204 | %cond = icmp slt i32 %ext, 0 |
| 205 | %res = select i1 %cond, double %a, double %b |
| 206 | ret double %res |
| 207 | } |
| 208 | |
| 209 | ; ...and another form |
| 210 | define double @f16(double %a, double %b, i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 211 | ; CHECK-LABEL: f16: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 212 | ; CHECK: cli 0(%r2), 127 |
Richard Sandiford | 586f417 | 2013-05-21 08:53:17 +0000 | [diff] [blame] | 213 | ; CHECK-NEXT: jh |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 214 | ; CHECK: br %r14 |
| 215 | %val = load i8 *%ptr |
| 216 | %ext = sext i8 %val to i32 |
| 217 | %cond = icmp sle i32 %ext, -1 |
| 218 | %res = select i1 %cond, double %a, double %b |
| 219 | ret double %res |
| 220 | } |