|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| 2 | +; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s |
| 3 | + |
| 4 | +define i32 @eq_i32(i32 %x) { |
| 5 | +; CHECK-LABEL: eq_i32: |
| 6 | +; CHECK: // %bb.0: |
| 7 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 8 | +; CHECK-NEXT: cmn w0, #512, lsl #12 // =2097152 |
| 9 | +; CHECK-NEXT: sub w8, w8, w0 |
| 10 | +; CHECK-NEXT: csel w0, w0, w8, eq |
| 11 | +; CHECK-NEXT: ret |
| 12 | + %cmp = icmp eq i32 %x, -2097152 |
| 13 | + %sub = sub i32 -2097152, %x |
| 14 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 15 | + ret i32 %retval.0 |
| 16 | +} |
| 17 | + |
| 18 | +define i32 @ne_i32(i32 %x) { |
| 19 | +; CHECK-LABEL: ne_i32: |
| 20 | +; CHECK: // %bb.0: |
| 21 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 22 | +; CHECK-NEXT: cmn w0, #512, lsl #12 // =2097152 |
| 23 | +; CHECK-NEXT: sub w8, w8, w0 |
| 24 | +; CHECK-NEXT: csel w0, w0, w8, ne |
| 25 | +; CHECK-NEXT: ret |
| 26 | + %cmp = icmp ne i32 %x, -2097152 |
| 27 | + %sub = sub i32 -2097152, %x |
| 28 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 29 | + ret i32 %retval.0 |
| 30 | +} |
| 31 | + |
| 32 | +define i32 @sgt_i32(i32 %x) { |
| 33 | +; CHECK-LABEL: sgt_i32: |
| 34 | +; CHECK: // %bb.0: |
| 35 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 36 | +; CHECK-NEXT: cmn w0, #512, lsl #12 // =2097152 |
| 37 | +; CHECK-NEXT: sub w8, w8, w0 |
| 38 | +; CHECK-NEXT: csel w0, w0, w8, gt |
| 39 | +; CHECK-NEXT: ret |
| 40 | + %cmp = icmp sgt i32 %x, -2097152 |
| 41 | + %sub = sub i32 -2097152, %x |
| 42 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 43 | + ret i32 %retval.0 |
| 44 | +} |
| 45 | + |
| 46 | +define i32 @sge_i32(i32 %x) { |
| 47 | +; CHECK-LABEL: sge_i32: |
| 48 | +; CHECK: // %bb.0: |
| 49 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 50 | +; CHECK-NEXT: mov w9, #-2097153 // =0xffdfffff |
| 51 | +; CHECK-NEXT: sub w8, w8, w0 |
| 52 | +; CHECK-NEXT: cmp w0, w9 |
| 53 | +; CHECK-NEXT: csel w0, w0, w8, gt |
| 54 | +; CHECK-NEXT: ret |
| 55 | + %cmp = icmp sge i32 %x, -2097152 |
| 56 | + %sub = sub i32 -2097152, %x |
| 57 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 58 | + ret i32 %retval.0 |
| 59 | +} |
| 60 | + |
| 61 | +define i32 @slt_i32(i32 %x) { |
| 62 | +; CHECK-LABEL: slt_i32: |
| 63 | +; CHECK: // %bb.0: |
| 64 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 65 | +; CHECK-NEXT: cmn w0, #512, lsl #12 // =2097152 |
| 66 | +; CHECK-NEXT: sub w8, w8, w0 |
| 67 | +; CHECK-NEXT: csel w0, w0, w8, lt |
| 68 | +; CHECK-NEXT: ret |
| 69 | + %cmp = icmp slt i32 %x, -2097152 |
| 70 | + %sub = sub i32 -2097152, %x |
| 71 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 72 | + ret i32 %retval.0 |
| 73 | +} |
| 74 | + |
| 75 | +define i32 @sle_i32(i32 %x) { |
| 76 | +; CHECK-LABEL: sle_i32: |
| 77 | +; CHECK: // %bb.0: |
| 78 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 79 | +; CHECK-NEXT: mov w9, #-2097151 // =0xffe00001 |
| 80 | +; CHECK-NEXT: sub w8, w8, w0 |
| 81 | +; CHECK-NEXT: cmp w0, w9 |
| 82 | +; CHECK-NEXT: csel w0, w0, w8, lt |
| 83 | +; CHECK-NEXT: ret |
| 84 | + %cmp = icmp sle i32 %x, -2097152 |
| 85 | + %sub = sub i32 -2097152, %x |
| 86 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 87 | + ret i32 %retval.0 |
| 88 | +} |
| 89 | + |
| 90 | +define i32 @ugt_i32(i32 %x) { |
| 91 | +; CHECK-LABEL: ugt_i32: |
| 92 | +; CHECK: // %bb.0: |
| 93 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 94 | +; CHECK-NEXT: cmn w0, #512, lsl #12 // =2097152 |
| 95 | +; CHECK-NEXT: sub w8, w8, w0 |
| 96 | +; CHECK-NEXT: csel w0, w0, w8, hi |
| 97 | +; CHECK-NEXT: ret |
| 98 | + %cmp = icmp ugt i32 %x, -2097152 |
| 99 | + %sub = sub i32 -2097152, %x |
| 100 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 101 | + ret i32 %retval.0 |
| 102 | +} |
| 103 | + |
| 104 | +define i32 @uge_i32(i32 %x) { |
| 105 | +; CHECK-LABEL: uge_i32: |
| 106 | +; CHECK: // %bb.0: |
| 107 | +; CHECK-NEXT: lsr w9, w0, #21 |
| 108 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 109 | +; CHECK-NEXT: sub w8, w8, w0 |
| 110 | +; CHECK-NEXT: cmp w9, #2046 |
| 111 | +; CHECK-NEXT: csel w0, w0, w8, hi |
| 112 | +; CHECK-NEXT: ret |
| 113 | + %cmp = icmp uge i32 %x, -2097152 |
| 114 | + %sub = sub i32 -2097152, %x |
| 115 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 116 | + ret i32 %retval.0 |
| 117 | +} |
| 118 | + |
| 119 | +define i32 @ult_i32(i32 %x) { |
| 120 | +; CHECK-LABEL: ult_i32: |
| 121 | +; CHECK: // %bb.0: |
| 122 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 123 | +; CHECK-NEXT: cmn w0, #512, lsl #12 // =2097152 |
| 124 | +; CHECK-NEXT: sub w8, w8, w0 |
| 125 | +; CHECK-NEXT: csel w0, w0, w8, lo |
| 126 | +; CHECK-NEXT: ret |
| 127 | + %cmp = icmp ult i32 %x, -2097152 |
| 128 | + %sub = sub i32 -2097152, %x |
| 129 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 130 | + ret i32 %retval.0 |
| 131 | +} |
| 132 | + |
| 133 | +define i32 @ule_i32(i32 %x) { |
| 134 | +; CHECK-LABEL: ule_i32: |
| 135 | +; CHECK: // %bb.0: |
| 136 | +; CHECK-NEXT: mov w8, #-2097152 // =0xffe00000 |
| 137 | +; CHECK-NEXT: mov w9, #-2097151 // =0xffe00001 |
| 138 | +; CHECK-NEXT: sub w8, w8, w0 |
| 139 | +; CHECK-NEXT: cmp w0, w9 |
| 140 | +; CHECK-NEXT: csel w0, w0, w8, lo |
| 141 | +; CHECK-NEXT: ret |
| 142 | + %cmp = icmp ule i32 %x, -2097152 |
| 143 | + %sub = sub i32 -2097152, %x |
| 144 | + %retval.0 = select i1 %cmp, i32 %x, i32 %sub |
| 145 | + ret i32 %retval.0 |
| 146 | +} |
| 147 | + |
| 148 | + |
| 149 | +define i64 @eq_i64(i64 %x) { |
| 150 | +; CHECK-LABEL: eq_i64: |
| 151 | +; CHECK: // %bb.0: |
| 152 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 153 | +; CHECK-NEXT: cmp x0, #100 |
| 154 | +; CHECK-NEXT: sub x8, x8, x0 |
| 155 | +; CHECK-NEXT: csel x0, x0, x8, eq |
| 156 | +; CHECK-NEXT: ret |
| 157 | + %cmp = icmp eq i64 %x, 100 |
| 158 | + %sub = sub i64 100, %x |
| 159 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 160 | + ret i64 %retval.0 |
| 161 | +} |
| 162 | + |
| 163 | +define i64 @ne_i64(i64 %x) { |
| 164 | +; CHECK-LABEL: ne_i64: |
| 165 | +; CHECK: // %bb.0: |
| 166 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 167 | +; CHECK-NEXT: cmp x0, #100 |
| 168 | +; CHECK-NEXT: sub x8, x8, x0 |
| 169 | +; CHECK-NEXT: csel x0, x0, x8, ne |
| 170 | +; CHECK-NEXT: ret |
| 171 | + %cmp = icmp ne i64 %x, 100 |
| 172 | + %sub = sub i64 100, %x |
| 173 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 174 | + ret i64 %retval.0 |
| 175 | +} |
| 176 | + |
| 177 | +define i64 @sgt_i64(i64 %x) { |
| 178 | +; CHECK-LABEL: sgt_i64: |
| 179 | +; CHECK: // %bb.0: |
| 180 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 181 | +; CHECK-NEXT: cmp x0, #100 |
| 182 | +; CHECK-NEXT: sub x8, x8, x0 |
| 183 | +; CHECK-NEXT: csel x0, x0, x8, gt |
| 184 | +; CHECK-NEXT: ret |
| 185 | + %cmp = icmp sgt i64 %x, 100 |
| 186 | + %sub = sub i64 100, %x |
| 187 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 188 | + ret i64 %retval.0 |
| 189 | +} |
| 190 | + |
| 191 | +define i64 @sge_i64(i64 %x) { |
| 192 | +; CHECK-LABEL: sge_i64: |
| 193 | +; CHECK: // %bb.0: |
| 194 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 195 | +; CHECK-NEXT: cmp x0, #99 |
| 196 | +; CHECK-NEXT: sub x8, x8, x0 |
| 197 | +; CHECK-NEXT: csel x0, x0, x8, gt |
| 198 | +; CHECK-NEXT: ret |
| 199 | + %cmp = icmp sge i64 %x, 100 |
| 200 | + %sub = sub i64 100, %x |
| 201 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 202 | + ret i64 %retval.0 |
| 203 | +} |
| 204 | + |
| 205 | +define i64 @slt_i64(i64 %x) { |
| 206 | +; CHECK-LABEL: slt_i64: |
| 207 | +; CHECK: // %bb.0: |
| 208 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 209 | +; CHECK-NEXT: cmp x0, #100 |
| 210 | +; CHECK-NEXT: sub x8, x8, x0 |
| 211 | +; CHECK-NEXT: csel x0, x0, x8, lt |
| 212 | +; CHECK-NEXT: ret |
| 213 | + %cmp = icmp slt i64 %x, 100 |
| 214 | + %sub = sub i64 100, %x |
| 215 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 216 | + ret i64 %retval.0 |
| 217 | +} |
| 218 | + |
| 219 | +define i64 @sle_i64(i64 %x) { |
| 220 | +; CHECK-LABEL: sle_i64: |
| 221 | +; CHECK: // %bb.0: |
| 222 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 223 | +; CHECK-NEXT: cmp x0, #101 |
| 224 | +; CHECK-NEXT: sub x8, x8, x0 |
| 225 | +; CHECK-NEXT: csel x0, x0, x8, lt |
| 226 | +; CHECK-NEXT: ret |
| 227 | + %cmp = icmp sle i64 %x, 100 |
| 228 | + %sub = sub i64 100, %x |
| 229 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 230 | + ret i64 %retval.0 |
| 231 | +} |
| 232 | + |
| 233 | +define i64 @ugt_i64(i64 %x) { |
| 234 | +; CHECK-LABEL: ugt_i64: |
| 235 | +; CHECK: // %bb.0: |
| 236 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 237 | +; CHECK-NEXT: cmp x0, #100 |
| 238 | +; CHECK-NEXT: sub x8, x8, x0 |
| 239 | +; CHECK-NEXT: csel x0, x0, x8, hi |
| 240 | +; CHECK-NEXT: ret |
| 241 | + %cmp = icmp ugt i64 %x, 100 |
| 242 | + %sub = sub i64 100, %x |
| 243 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 244 | + ret i64 %retval.0 |
| 245 | +} |
| 246 | + |
| 247 | +define i64 @uge_i64(i64 %x) { |
| 248 | +; CHECK-LABEL: uge_i64: |
| 249 | +; CHECK: // %bb.0: |
| 250 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 251 | +; CHECK-NEXT: cmp x0, #99 |
| 252 | +; CHECK-NEXT: sub x8, x8, x0 |
| 253 | +; CHECK-NEXT: csel x0, x0, x8, hi |
| 254 | +; CHECK-NEXT: ret |
| 255 | + %cmp = icmp uge i64 %x, 100 |
| 256 | + %sub = sub i64 100, %x |
| 257 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 258 | + ret i64 %retval.0 |
| 259 | +} |
| 260 | + |
| 261 | +define i64 @ult_i64(i64 %x) { |
| 262 | +; CHECK-LABEL: ult_i64: |
| 263 | +; CHECK: // %bb.0: |
| 264 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 265 | +; CHECK-NEXT: cmp x0, #100 |
| 266 | +; CHECK-NEXT: sub x8, x8, x0 |
| 267 | +; CHECK-NEXT: csel x0, x0, x8, lo |
| 268 | +; CHECK-NEXT: ret |
| 269 | + %cmp = icmp ult i64 %x, 100 |
| 270 | + %sub = sub i64 100, %x |
| 271 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 272 | + ret i64 %retval.0 |
| 273 | +} |
| 274 | + |
| 275 | +define i64 @ule_i64(i64 %x) { |
| 276 | +; CHECK-LABEL: ule_i64: |
| 277 | +; CHECK: // %bb.0: |
| 278 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 279 | +; CHECK-NEXT: cmp x0, #101 |
| 280 | +; CHECK-NEXT: sub x8, x8, x0 |
| 281 | +; CHECK-NEXT: csel x0, x0, x8, lo |
| 282 | +; CHECK-NEXT: ret |
| 283 | + %cmp = icmp ule i64 %x, 100 |
| 284 | + %sub = sub i64 100, %x |
| 285 | + %retval.0 = select i1 %cmp, i64 %x, i64 %sub |
| 286 | + ret i64 %retval.0 |
| 287 | +} |
| 288 | + |
| 289 | + |
| 290 | +define i64 @both(i64 %x) { |
| 291 | +; CHECK-LABEL: both: |
| 292 | +; CHECK: // %bb.0: |
| 293 | +; CHECK-NEXT: mov w8, #100 // =0x64 |
| 294 | +; CHECK-NEXT: sub x9, x0, #100 |
| 295 | +; CHECK-NEXT: cmp x0, #101 |
| 296 | +; CHECK-NEXT: sub x8, x8, x0 |
| 297 | +; CHECK-NEXT: csel x0, x8, x9, lo |
| 298 | +; CHECK-NEXT: ret |
| 299 | + %cmp = icmp ule i64 %x, 100 |
| 300 | + %sub1 = sub i64 100, %x |
| 301 | + %sub2 = sub i64 %x, 100 |
| 302 | + %retval.0 = select i1 %cmp, i64 %sub1, i64 %sub2 |
| 303 | + ret i64 %retval.0 |
| 304 | +} |
| 305 | + |
| 306 | +define i32 @qabs(i32 %0) { |
| 307 | +; CHECK-LABEL: qabs: |
| 308 | +; CHECK: // %bb.0: |
| 309 | +; CHECK-NEXT: mov w8, #-2147483648 // =0x80000000 |
| 310 | +; CHECK-NEXT: cmp w0, w8 |
| 311 | +; CHECK-NEXT: mov w8, #2147483647 // =0x7fffffff |
| 312 | +; CHECK-NEXT: csneg w8, w8, w0, eq |
| 313 | +; CHECK-NEXT: cmp w0, #0 |
| 314 | +; CHECK-NEXT: csel w0, w0, w8, gt |
| 315 | +; CHECK-NEXT: ret |
| 316 | + %cmp1 = icmp sgt i32 %0, 0 |
| 317 | + %cmp2 = icmp eq i32 %0, -2147483648 |
| 318 | + %sub = sub nsw i32 0, %0 |
| 319 | + %cond = select i1 %cmp2, i32 2147483647, i32 %sub |
| 320 | + %cond6 = select i1 %cmp1, i32 %0, i32 %cond |
| 321 | + ret i32 %cond6 |
| 322 | +} |
0 commit comments