1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 ; RUN: llc -mtriple=x86_64-darwin-unknown < %s | FileCheck %s --check-prefix=SDAG 3 ; RUN: llc -mtriple=x86_64-darwin-unknown -fast-isel -fast-isel-abort=1 < %s | FileCheck %s --check-prefix=FAST 4 ; RUN: llc -mtriple=x86_64-darwin-unknown -mcpu=knl < %s | FileCheck %s --check-prefix=KNL 5 6 ; 7 ; Get the actual value of the overflow bit. 8 ; 9 ; SADDO reg, reg 10 define zeroext i1 @saddoi8(i8 signext %v1, i8 signext %v2, i8* %res) { 11 ; SDAG-LABEL: saddoi8: 12 ; SDAG: ## %bb.0: 13 ; SDAG-NEXT: addb %sil, %dil 14 ; SDAG-NEXT: seto %al 15 ; SDAG-NEXT: movb %dil, (%rdx) 16 ; SDAG-NEXT: retq 17 ; 18 ; FAST-LABEL: saddoi8: 19 ; FAST: ## %bb.0: 20 ; FAST-NEXT: addb %sil, %dil 21 ; FAST-NEXT: seto %al 22 ; FAST-NEXT: movb %dil, (%rdx) 23 ; FAST-NEXT: andb $1, %al 24 ; FAST-NEXT: movzbl %al, %eax 25 ; FAST-NEXT: retq 26 ; 27 ; KNL-LABEL: saddoi8: 28 ; KNL: ## %bb.0: 29 ; KNL-NEXT: addb %sil, %dil 30 ; KNL-NEXT: seto %al 31 ; KNL-NEXT: movb %dil, (%rdx) 32 ; KNL-NEXT: retq 33 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 %v1, i8 %v2) 34 %val = extractvalue {i8, i1} %t, 0 35 %obit = extractvalue {i8, i1} %t, 1 36 store i8 %val, i8* %res 37 ret i1 %obit 38 } 39 40 define zeroext i1 @saddoi16(i16 %v1, i16 %v2, i16* %res) { 41 ; SDAG-LABEL: saddoi16: 42 ; SDAG: ## %bb.0: 43 ; SDAG-NEXT: addw %si, %di 44 ; SDAG-NEXT: seto %al 45 ; SDAG-NEXT: movw %di, (%rdx) 46 ; SDAG-NEXT: retq 47 ; 48 ; FAST-LABEL: saddoi16: 49 ; FAST: ## %bb.0: 50 ; FAST-NEXT: addw %si, %di 51 ; FAST-NEXT: seto %al 52 ; FAST-NEXT: movw %di, (%rdx) 53 ; FAST-NEXT: andb $1, %al 54 ; FAST-NEXT: movzbl %al, %eax 55 ; FAST-NEXT: retq 56 ; 57 ; KNL-LABEL: saddoi16: 58 ; KNL: ## %bb.0: 59 ; KNL-NEXT: addw %si, %di 60 ; KNL-NEXT: seto %al 61 ; KNL-NEXT: movw %di, (%rdx) 62 ; KNL-NEXT: retq 63 %t = call {i16, i1} @llvm.sadd.with.overflow.i16(i16 %v1, i16 %v2) 64 %val = extractvalue {i16, i1} %t, 0 65 %obit = extractvalue {i16, i1} %t, 1 66 store i16 %val, i16* %res 67 ret i1 %obit 68 } 69 70 define zeroext i1 @saddoi32(i32 %v1, i32 %v2, i32* %res) { 71 ; SDAG-LABEL: saddoi32: 72 ; SDAG: ## %bb.0: 73 ; SDAG-NEXT: addl %esi, %edi 74 ; SDAG-NEXT: seto %al 75 ; SDAG-NEXT: movl %edi, (%rdx) 76 ; SDAG-NEXT: retq 77 ; 78 ; FAST-LABEL: saddoi32: 79 ; FAST: ## %bb.0: 80 ; FAST-NEXT: addl %esi, %edi 81 ; FAST-NEXT: seto %al 82 ; FAST-NEXT: movl %edi, (%rdx) 83 ; FAST-NEXT: andb $1, %al 84 ; FAST-NEXT: movzbl %al, %eax 85 ; FAST-NEXT: retq 86 ; 87 ; KNL-LABEL: saddoi32: 88 ; KNL: ## %bb.0: 89 ; KNL-NEXT: addl %esi, %edi 90 ; KNL-NEXT: seto %al 91 ; KNL-NEXT: movl %edi, (%rdx) 92 ; KNL-NEXT: retq 93 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2) 94 %val = extractvalue {i32, i1} %t, 0 95 %obit = extractvalue {i32, i1} %t, 1 96 store i32 %val, i32* %res 97 ret i1 %obit 98 } 99 100 define zeroext i1 @saddoi64(i64 %v1, i64 %v2, i64* %res) { 101 ; SDAG-LABEL: saddoi64: 102 ; SDAG: ## %bb.0: 103 ; SDAG-NEXT: addq %rsi, %rdi 104 ; SDAG-NEXT: seto %al 105 ; SDAG-NEXT: movq %rdi, (%rdx) 106 ; SDAG-NEXT: retq 107 ; 108 ; FAST-LABEL: saddoi64: 109 ; FAST: ## %bb.0: 110 ; FAST-NEXT: addq %rsi, %rdi 111 ; FAST-NEXT: seto %al 112 ; FAST-NEXT: movq %rdi, (%rdx) 113 ; FAST-NEXT: andb $1, %al 114 ; FAST-NEXT: movzbl %al, %eax 115 ; FAST-NEXT: retq 116 ; 117 ; KNL-LABEL: saddoi64: 118 ; KNL: ## %bb.0: 119 ; KNL-NEXT: addq %rsi, %rdi 120 ; KNL-NEXT: seto %al 121 ; KNL-NEXT: movq %rdi, (%rdx) 122 ; KNL-NEXT: retq 123 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2) 124 %val = extractvalue {i64, i1} %t, 0 125 %obit = extractvalue {i64, i1} %t, 1 126 store i64 %val, i64* %res 127 ret i1 %obit 128 } 129 130 ; SADDO reg, 1 | INC 131 define zeroext i1 @saddoinci8(i8 %v1, i8* %res) { 132 ; SDAG-LABEL: saddoinci8: 133 ; SDAG: ## %bb.0: 134 ; SDAG-NEXT: incb %dil 135 ; SDAG-NEXT: seto %al 136 ; SDAG-NEXT: movb %dil, (%rsi) 137 ; SDAG-NEXT: retq 138 ; 139 ; FAST-LABEL: saddoinci8: 140 ; FAST: ## %bb.0: 141 ; FAST-NEXT: incb %dil 142 ; FAST-NEXT: seto %al 143 ; FAST-NEXT: movb %dil, (%rsi) 144 ; FAST-NEXT: andb $1, %al 145 ; FAST-NEXT: movzbl %al, %eax 146 ; FAST-NEXT: retq 147 ; 148 ; KNL-LABEL: saddoinci8: 149 ; KNL: ## %bb.0: 150 ; KNL-NEXT: incb %dil 151 ; KNL-NEXT: seto %al 152 ; KNL-NEXT: movb %dil, (%rsi) 153 ; KNL-NEXT: retq 154 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 %v1, i8 1) 155 %val = extractvalue {i8, i1} %t, 0 156 %obit = extractvalue {i8, i1} %t, 1 157 store i8 %val, i8* %res 158 ret i1 %obit 159 } 160 161 define zeroext i1 @saddoinci16(i16 %v1, i16* %res) { 162 ; SDAG-LABEL: saddoinci16: 163 ; SDAG: ## %bb.0: 164 ; SDAG-NEXT: incw %di 165 ; SDAG-NEXT: seto %al 166 ; SDAG-NEXT: movw %di, (%rsi) 167 ; SDAG-NEXT: retq 168 ; 169 ; FAST-LABEL: saddoinci16: 170 ; FAST: ## %bb.0: 171 ; FAST-NEXT: incw %di 172 ; FAST-NEXT: seto %al 173 ; FAST-NEXT: movw %di, (%rsi) 174 ; FAST-NEXT: andb $1, %al 175 ; FAST-NEXT: movzbl %al, %eax 176 ; FAST-NEXT: retq 177 ; 178 ; KNL-LABEL: saddoinci16: 179 ; KNL: ## %bb.0: 180 ; KNL-NEXT: incw %di 181 ; KNL-NEXT: seto %al 182 ; KNL-NEXT: movw %di, (%rsi) 183 ; KNL-NEXT: retq 184 %t = call {i16, i1} @llvm.sadd.with.overflow.i16(i16 %v1, i16 1) 185 %val = extractvalue {i16, i1} %t, 0 186 %obit = extractvalue {i16, i1} %t, 1 187 store i16 %val, i16* %res 188 ret i1 %obit 189 } 190 191 define zeroext i1 @saddoinci32(i32 %v1, i32* %res) { 192 ; SDAG-LABEL: saddoinci32: 193 ; SDAG: ## %bb.0: 194 ; SDAG-NEXT: incl %edi 195 ; SDAG-NEXT: seto %al 196 ; SDAG-NEXT: movl %edi, (%rsi) 197 ; SDAG-NEXT: retq 198 ; 199 ; FAST-LABEL: saddoinci32: 200 ; FAST: ## %bb.0: 201 ; FAST-NEXT: incl %edi 202 ; FAST-NEXT: seto %al 203 ; FAST-NEXT: movl %edi, (%rsi) 204 ; FAST-NEXT: andb $1, %al 205 ; FAST-NEXT: movzbl %al, %eax 206 ; FAST-NEXT: retq 207 ; 208 ; KNL-LABEL: saddoinci32: 209 ; KNL: ## %bb.0: 210 ; KNL-NEXT: incl %edi 211 ; KNL-NEXT: seto %al 212 ; KNL-NEXT: movl %edi, (%rsi) 213 ; KNL-NEXT: retq 214 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 1) 215 %val = extractvalue {i32, i1} %t, 0 216 %obit = extractvalue {i32, i1} %t, 1 217 store i32 %val, i32* %res 218 ret i1 %obit 219 } 220 221 define zeroext i1 @saddoinci64(i64 %v1, i64* %res) { 222 ; SDAG-LABEL: saddoinci64: 223 ; SDAG: ## %bb.0: 224 ; SDAG-NEXT: incq %rdi 225 ; SDAG-NEXT: seto %al 226 ; SDAG-NEXT: movq %rdi, (%rsi) 227 ; SDAG-NEXT: retq 228 ; 229 ; FAST-LABEL: saddoinci64: 230 ; FAST: ## %bb.0: 231 ; FAST-NEXT: incq %rdi 232 ; FAST-NEXT: seto %al 233 ; FAST-NEXT: movq %rdi, (%rsi) 234 ; FAST-NEXT: andb $1, %al 235 ; FAST-NEXT: movzbl %al, %eax 236 ; FAST-NEXT: retq 237 ; 238 ; KNL-LABEL: saddoinci64: 239 ; KNL: ## %bb.0: 240 ; KNL-NEXT: incq %rdi 241 ; KNL-NEXT: seto %al 242 ; KNL-NEXT: movq %rdi, (%rsi) 243 ; KNL-NEXT: retq 244 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 1) 245 %val = extractvalue {i64, i1} %t, 0 246 %obit = extractvalue {i64, i1} %t, 1 247 store i64 %val, i64* %res 248 ret i1 %obit 249 } 250 251 ; SADDO reg, imm | imm, reg 252 ; FIXME: DAG doesn't optimize immediates on the LHS. 253 define zeroext i1 @saddoi64imm1(i64 %v1, i64* %res) { 254 ; SDAG-LABEL: saddoi64imm1: 255 ; SDAG: ## %bb.0: 256 ; SDAG-NEXT: movl $2, %ecx 257 ; SDAG-NEXT: addq %rdi, %rcx 258 ; SDAG-NEXT: seto %al 259 ; SDAG-NEXT: movq %rcx, (%rsi) 260 ; SDAG-NEXT: retq 261 ; 262 ; FAST-LABEL: saddoi64imm1: 263 ; FAST: ## %bb.0: 264 ; FAST-NEXT: addq $2, %rdi 265 ; FAST-NEXT: seto %al 266 ; FAST-NEXT: movq %rdi, (%rsi) 267 ; FAST-NEXT: andb $1, %al 268 ; FAST-NEXT: movzbl %al, %eax 269 ; FAST-NEXT: retq 270 ; 271 ; KNL-LABEL: saddoi64imm1: 272 ; KNL: ## %bb.0: 273 ; KNL-NEXT: movl $2, %ecx 274 ; KNL-NEXT: addq %rdi, %rcx 275 ; KNL-NEXT: seto %al 276 ; KNL-NEXT: movq %rcx, (%rsi) 277 ; KNL-NEXT: retq 278 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 2, i64 %v1) 279 %val = extractvalue {i64, i1} %t, 0 280 %obit = extractvalue {i64, i1} %t, 1 281 store i64 %val, i64* %res 282 ret i1 %obit 283 } 284 285 ; Check boundary conditions for large immediates. 286 define zeroext i1 @saddoi64imm2(i64 %v1, i64* %res) { 287 ; SDAG-LABEL: saddoi64imm2: 288 ; SDAG: ## %bb.0: 289 ; SDAG-NEXT: addq $-2147483648, %rdi ## imm = 0x80000000 290 ; SDAG-NEXT: seto %al 291 ; SDAG-NEXT: movq %rdi, (%rsi) 292 ; SDAG-NEXT: retq 293 ; 294 ; FAST-LABEL: saddoi64imm2: 295 ; FAST: ## %bb.0: 296 ; FAST-NEXT: addq $-2147483648, %rdi ## imm = 0x80000000 297 ; FAST-NEXT: seto %al 298 ; FAST-NEXT: movq %rdi, (%rsi) 299 ; FAST-NEXT: andb $1, %al 300 ; FAST-NEXT: movzbl %al, %eax 301 ; FAST-NEXT: retq 302 ; 303 ; KNL-LABEL: saddoi64imm2: 304 ; KNL: ## %bb.0: 305 ; KNL-NEXT: addq $-2147483648, %rdi ## imm = 0x80000000 306 ; KNL-NEXT: seto %al 307 ; KNL-NEXT: movq %rdi, (%rsi) 308 ; KNL-NEXT: retq 309 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 -2147483648) 310 %val = extractvalue {i64, i1} %t, 0 311 %obit = extractvalue {i64, i1} %t, 1 312 store i64 %val, i64* %res 313 ret i1 %obit 314 } 315 316 define zeroext i1 @saddoi64imm3(i64 %v1, i64* %res) { 317 ; SDAG-LABEL: saddoi64imm3: 318 ; SDAG: ## %bb.0: 319 ; SDAG-NEXT: movabsq $-21474836489, %rcx ## imm = 0xFFFFFFFAFFFFFFF7 320 ; SDAG-NEXT: addq %rdi, %rcx 321 ; SDAG-NEXT: seto %al 322 ; SDAG-NEXT: movq %rcx, (%rsi) 323 ; SDAG-NEXT: retq 324 ; 325 ; FAST-LABEL: saddoi64imm3: 326 ; FAST: ## %bb.0: 327 ; FAST-NEXT: movabsq $-21474836489, %rax ## imm = 0xFFFFFFFAFFFFFFF7 328 ; FAST-NEXT: addq %rdi, %rax 329 ; FAST-NEXT: seto %cl 330 ; FAST-NEXT: movq %rax, (%rsi) 331 ; FAST-NEXT: andb $1, %cl 332 ; FAST-NEXT: movzbl %cl, %eax 333 ; FAST-NEXT: retq 334 ; 335 ; KNL-LABEL: saddoi64imm3: 336 ; KNL: ## %bb.0: 337 ; KNL-NEXT: movabsq $-21474836489, %rcx ## imm = 0xFFFFFFFAFFFFFFF7 338 ; KNL-NEXT: addq %rdi, %rcx 339 ; KNL-NEXT: seto %al 340 ; KNL-NEXT: movq %rcx, (%rsi) 341 ; KNL-NEXT: retq 342 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 -21474836489) 343 %val = extractvalue {i64, i1} %t, 0 344 %obit = extractvalue {i64, i1} %t, 1 345 store i64 %val, i64* %res 346 ret i1 %obit 347 } 348 349 define zeroext i1 @saddoi64imm4(i64 %v1, i64* %res) { 350 ; SDAG-LABEL: saddoi64imm4: 351 ; SDAG: ## %bb.0: 352 ; SDAG-NEXT: addq $2147483647, %rdi ## imm = 0x7FFFFFFF 353 ; SDAG-NEXT: seto %al 354 ; SDAG-NEXT: movq %rdi, (%rsi) 355 ; SDAG-NEXT: retq 356 ; 357 ; FAST-LABEL: saddoi64imm4: 358 ; FAST: ## %bb.0: 359 ; FAST-NEXT: addq $2147483647, %rdi ## imm = 0x7FFFFFFF 360 ; FAST-NEXT: seto %al 361 ; FAST-NEXT: movq %rdi, (%rsi) 362 ; FAST-NEXT: andb $1, %al 363 ; FAST-NEXT: movzbl %al, %eax 364 ; FAST-NEXT: retq 365 ; 366 ; KNL-LABEL: saddoi64imm4: 367 ; KNL: ## %bb.0: 368 ; KNL-NEXT: addq $2147483647, %rdi ## imm = 0x7FFFFFFF 369 ; KNL-NEXT: seto %al 370 ; KNL-NEXT: movq %rdi, (%rsi) 371 ; KNL-NEXT: retq 372 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 2147483647) 373 %val = extractvalue {i64, i1} %t, 0 374 %obit = extractvalue {i64, i1} %t, 1 375 store i64 %val, i64* %res 376 ret i1 %obit 377 } 378 379 define zeroext i1 @saddoi64imm5(i64 %v1, i64* %res) { 380 ; SDAG-LABEL: saddoi64imm5: 381 ; SDAG: ## %bb.0: 382 ; SDAG-NEXT: movl $2147483648, %ecx ## imm = 0x80000000 383 ; SDAG-NEXT: addq %rdi, %rcx 384 ; SDAG-NEXT: seto %al 385 ; SDAG-NEXT: movq %rcx, (%rsi) 386 ; SDAG-NEXT: retq 387 ; 388 ; FAST-LABEL: saddoi64imm5: 389 ; FAST: ## %bb.0: 390 ; FAST-NEXT: movl $2147483648, %eax ## imm = 0x80000000 391 ; FAST-NEXT: addq %rdi, %rax 392 ; FAST-NEXT: seto %cl 393 ; FAST-NEXT: movq %rax, (%rsi) 394 ; FAST-NEXT: andb $1, %cl 395 ; FAST-NEXT: movzbl %cl, %eax 396 ; FAST-NEXT: retq 397 ; 398 ; KNL-LABEL: saddoi64imm5: 399 ; KNL: ## %bb.0: 400 ; KNL-NEXT: movl $2147483648, %ecx ## imm = 0x80000000 401 ; KNL-NEXT: addq %rdi, %rcx 402 ; KNL-NEXT: seto %al 403 ; KNL-NEXT: movq %rcx, (%rsi) 404 ; KNL-NEXT: retq 405 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 2147483648) 406 %val = extractvalue {i64, i1} %t, 0 407 %obit = extractvalue {i64, i1} %t, 1 408 store i64 %val, i64* %res 409 ret i1 %obit 410 } 411 412 ; UADDO 413 define zeroext i1 @uaddoi32(i32 %v1, i32 %v2, i32* %res) { 414 ; SDAG-LABEL: uaddoi32: 415 ; SDAG: ## %bb.0: 416 ; SDAG-NEXT: addl %esi, %edi 417 ; SDAG-NEXT: setb %al 418 ; SDAG-NEXT: movl %edi, (%rdx) 419 ; SDAG-NEXT: retq 420 ; 421 ; FAST-LABEL: uaddoi32: 422 ; FAST: ## %bb.0: 423 ; FAST-NEXT: addl %esi, %edi 424 ; FAST-NEXT: setb %al 425 ; FAST-NEXT: movl %edi, (%rdx) 426 ; FAST-NEXT: andb $1, %al 427 ; FAST-NEXT: movzbl %al, %eax 428 ; FAST-NEXT: retq 429 ; 430 ; KNL-LABEL: uaddoi32: 431 ; KNL: ## %bb.0: 432 ; KNL-NEXT: addl %esi, %edi 433 ; KNL-NEXT: setb %al 434 ; KNL-NEXT: movl %edi, (%rdx) 435 ; KNL-NEXT: retq 436 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2) 437 %val = extractvalue {i32, i1} %t, 0 438 %obit = extractvalue {i32, i1} %t, 1 439 store i32 %val, i32* %res 440 ret i1 %obit 441 } 442 443 define zeroext i1 @uaddoi64(i64 %v1, i64 %v2, i64* %res) { 444 ; SDAG-LABEL: uaddoi64: 445 ; SDAG: ## %bb.0: 446 ; SDAG-NEXT: addq %rsi, %rdi 447 ; SDAG-NEXT: setb %al 448 ; SDAG-NEXT: movq %rdi, (%rdx) 449 ; SDAG-NEXT: retq 450 ; 451 ; FAST-LABEL: uaddoi64: 452 ; FAST: ## %bb.0: 453 ; FAST-NEXT: addq %rsi, %rdi 454 ; FAST-NEXT: setb %al 455 ; FAST-NEXT: movq %rdi, (%rdx) 456 ; FAST-NEXT: andb $1, %al 457 ; FAST-NEXT: movzbl %al, %eax 458 ; FAST-NEXT: retq 459 ; 460 ; KNL-LABEL: uaddoi64: 461 ; KNL: ## %bb.0: 462 ; KNL-NEXT: addq %rsi, %rdi 463 ; KNL-NEXT: setb %al 464 ; KNL-NEXT: movq %rdi, (%rdx) 465 ; KNL-NEXT: retq 466 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2) 467 %val = extractvalue {i64, i1} %t, 0 468 %obit = extractvalue {i64, i1} %t, 1 469 store i64 %val, i64* %res 470 ret i1 %obit 471 } 472 473 ; UADDO reg, 1 | NOT INC 474 define zeroext i1 @uaddoinci8(i8 %v1, i8* %res) { 475 ; SDAG-LABEL: uaddoinci8: 476 ; SDAG: ## %bb.0: 477 ; SDAG-NEXT: addb $1, %dil 478 ; SDAG-NEXT: setb %al 479 ; SDAG-NEXT: movb %dil, (%rsi) 480 ; SDAG-NEXT: retq 481 ; 482 ; FAST-LABEL: uaddoinci8: 483 ; FAST: ## %bb.0: 484 ; FAST-NEXT: addb $1, %dil 485 ; FAST-NEXT: setb %al 486 ; FAST-NEXT: movb %dil, (%rsi) 487 ; FAST-NEXT: andb $1, %al 488 ; FAST-NEXT: movzbl %al, %eax 489 ; FAST-NEXT: retq 490 ; 491 ; KNL-LABEL: uaddoinci8: 492 ; KNL: ## %bb.0: 493 ; KNL-NEXT: addb $1, %dil 494 ; KNL-NEXT: setb %al 495 ; KNL-NEXT: movb %dil, (%rsi) 496 ; KNL-NEXT: retq 497 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 %v1, i8 1) 498 %val = extractvalue {i8, i1} %t, 0 499 %obit = extractvalue {i8, i1} %t, 1 500 store i8 %val, i8* %res 501 ret i1 %obit 502 } 503 504 define zeroext i1 @uaddoinci16(i16 %v1, i16* %res) { 505 ; SDAG-LABEL: uaddoinci16: 506 ; SDAG: ## %bb.0: 507 ; SDAG-NEXT: addw $1, %di 508 ; SDAG-NEXT: setb %al 509 ; SDAG-NEXT: movw %di, (%rsi) 510 ; SDAG-NEXT: retq 511 ; 512 ; FAST-LABEL: uaddoinci16: 513 ; FAST: ## %bb.0: 514 ; FAST-NEXT: addw $1, %di 515 ; FAST-NEXT: setb %al 516 ; FAST-NEXT: movw %di, (%rsi) 517 ; FAST-NEXT: andb $1, %al 518 ; FAST-NEXT: movzbl %al, %eax 519 ; FAST-NEXT: retq 520 ; 521 ; KNL-LABEL: uaddoinci16: 522 ; KNL: ## %bb.0: 523 ; KNL-NEXT: addw $1, %di 524 ; KNL-NEXT: setb %al 525 ; KNL-NEXT: movw %di, (%rsi) 526 ; KNL-NEXT: retq 527 %t = call {i16, i1} @llvm.uadd.with.overflow.i16(i16 %v1, i16 1) 528 %val = extractvalue {i16, i1} %t, 0 529 %obit = extractvalue {i16, i1} %t, 1 530 store i16 %val, i16* %res 531 ret i1 %obit 532 } 533 534 define zeroext i1 @uaddoinci32(i32 %v1, i32* %res) { 535 ; SDAG-LABEL: uaddoinci32: 536 ; SDAG: ## %bb.0: 537 ; SDAG-NEXT: addl $1, %edi 538 ; SDAG-NEXT: setb %al 539 ; SDAG-NEXT: movl %edi, (%rsi) 540 ; SDAG-NEXT: retq 541 ; 542 ; FAST-LABEL: uaddoinci32: 543 ; FAST: ## %bb.0: 544 ; FAST-NEXT: addl $1, %edi 545 ; FAST-NEXT: setb %al 546 ; FAST-NEXT: movl %edi, (%rsi) 547 ; FAST-NEXT: andb $1, %al 548 ; FAST-NEXT: movzbl %al, %eax 549 ; FAST-NEXT: retq 550 ; 551 ; KNL-LABEL: uaddoinci32: 552 ; KNL: ## %bb.0: 553 ; KNL-NEXT: addl $1, %edi 554 ; KNL-NEXT: setb %al 555 ; KNL-NEXT: movl %edi, (%rsi) 556 ; KNL-NEXT: retq 557 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 1) 558 %val = extractvalue {i32, i1} %t, 0 559 %obit = extractvalue {i32, i1} %t, 1 560 store i32 %val, i32* %res 561 ret i1 %obit 562 } 563 564 define zeroext i1 @uaddoinci64(i64 %v1, i64* %res) { 565 ; SDAG-LABEL: uaddoinci64: 566 ; SDAG: ## %bb.0: 567 ; SDAG-NEXT: addq $1, %rdi 568 ; SDAG-NEXT: setb %al 569 ; SDAG-NEXT: movq %rdi, (%rsi) 570 ; SDAG-NEXT: retq 571 ; 572 ; FAST-LABEL: uaddoinci64: 573 ; FAST: ## %bb.0: 574 ; FAST-NEXT: addq $1, %rdi 575 ; FAST-NEXT: setb %al 576 ; FAST-NEXT: movq %rdi, (%rsi) 577 ; FAST-NEXT: andb $1, %al 578 ; FAST-NEXT: movzbl %al, %eax 579 ; FAST-NEXT: retq 580 ; 581 ; KNL-LABEL: uaddoinci64: 582 ; KNL: ## %bb.0: 583 ; KNL-NEXT: addq $1, %rdi 584 ; KNL-NEXT: setb %al 585 ; KNL-NEXT: movq %rdi, (%rsi) 586 ; KNL-NEXT: retq 587 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 1) 588 %val = extractvalue {i64, i1} %t, 0 589 %obit = extractvalue {i64, i1} %t, 1 590 store i64 %val, i64* %res 591 ret i1 %obit 592 } 593 594 ; SSUBO 595 define zeroext i1 @ssuboi32(i32 %v1, i32 %v2, i32* %res) { 596 ; SDAG-LABEL: ssuboi32: 597 ; SDAG: ## %bb.0: 598 ; SDAG-NEXT: subl %esi, %edi 599 ; SDAG-NEXT: seto %al 600 ; SDAG-NEXT: movl %edi, (%rdx) 601 ; SDAG-NEXT: retq 602 ; 603 ; FAST-LABEL: ssuboi32: 604 ; FAST: ## %bb.0: 605 ; FAST-NEXT: subl %esi, %edi 606 ; FAST-NEXT: seto %al 607 ; FAST-NEXT: movl %edi, (%rdx) 608 ; FAST-NEXT: andb $1, %al 609 ; FAST-NEXT: movzbl %al, %eax 610 ; FAST-NEXT: retq 611 ; 612 ; KNL-LABEL: ssuboi32: 613 ; KNL: ## %bb.0: 614 ; KNL-NEXT: subl %esi, %edi 615 ; KNL-NEXT: seto %al 616 ; KNL-NEXT: movl %edi, (%rdx) 617 ; KNL-NEXT: retq 618 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2) 619 %val = extractvalue {i32, i1} %t, 0 620 %obit = extractvalue {i32, i1} %t, 1 621 store i32 %val, i32* %res 622 ret i1 %obit 623 } 624 625 define zeroext i1 @ssuboi64(i64 %v1, i64 %v2, i64* %res) { 626 ; SDAG-LABEL: ssuboi64: 627 ; SDAG: ## %bb.0: 628 ; SDAG-NEXT: subq %rsi, %rdi 629 ; SDAG-NEXT: seto %al 630 ; SDAG-NEXT: movq %rdi, (%rdx) 631 ; SDAG-NEXT: retq 632 ; 633 ; FAST-LABEL: ssuboi64: 634 ; FAST: ## %bb.0: 635 ; FAST-NEXT: subq %rsi, %rdi 636 ; FAST-NEXT: seto %al 637 ; FAST-NEXT: movq %rdi, (%rdx) 638 ; FAST-NEXT: andb $1, %al 639 ; FAST-NEXT: movzbl %al, %eax 640 ; FAST-NEXT: retq 641 ; 642 ; KNL-LABEL: ssuboi64: 643 ; KNL: ## %bb.0: 644 ; KNL-NEXT: subq %rsi, %rdi 645 ; KNL-NEXT: seto %al 646 ; KNL-NEXT: movq %rdi, (%rdx) 647 ; KNL-NEXT: retq 648 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2) 649 %val = extractvalue {i64, i1} %t, 0 650 %obit = extractvalue {i64, i1} %t, 1 651 store i64 %val, i64* %res 652 ret i1 %obit 653 } 654 655 ; USUBO 656 define zeroext i1 @usuboi32(i32 %v1, i32 %v2, i32* %res) { 657 ; SDAG-LABEL: usuboi32: 658 ; SDAG: ## %bb.0: 659 ; SDAG-NEXT: subl %esi, %edi 660 ; SDAG-NEXT: setb %al 661 ; SDAG-NEXT: movl %edi, (%rdx) 662 ; SDAG-NEXT: retq 663 ; 664 ; FAST-LABEL: usuboi32: 665 ; FAST: ## %bb.0: 666 ; FAST-NEXT: subl %esi, %edi 667 ; FAST-NEXT: setb %al 668 ; FAST-NEXT: movl %edi, (%rdx) 669 ; FAST-NEXT: andb $1, %al 670 ; FAST-NEXT: movzbl %al, %eax 671 ; FAST-NEXT: retq 672 ; 673 ; KNL-LABEL: usuboi32: 674 ; KNL: ## %bb.0: 675 ; KNL-NEXT: subl %esi, %edi 676 ; KNL-NEXT: setb %al 677 ; KNL-NEXT: movl %edi, (%rdx) 678 ; KNL-NEXT: retq 679 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2) 680 %val = extractvalue {i32, i1} %t, 0 681 %obit = extractvalue {i32, i1} %t, 1 682 store i32 %val, i32* %res 683 ret i1 %obit 684 } 685 686 define zeroext i1 @usuboi64(i64 %v1, i64 %v2, i64* %res) { 687 ; SDAG-LABEL: usuboi64: 688 ; SDAG: ## %bb.0: 689 ; SDAG-NEXT: subq %rsi, %rdi 690 ; SDAG-NEXT: setb %al 691 ; SDAG-NEXT: movq %rdi, (%rdx) 692 ; SDAG-NEXT: retq 693 ; 694 ; FAST-LABEL: usuboi64: 695 ; FAST: ## %bb.0: 696 ; FAST-NEXT: subq %rsi, %rdi 697 ; FAST-NEXT: setb %al 698 ; FAST-NEXT: movq %rdi, (%rdx) 699 ; FAST-NEXT: andb $1, %al 700 ; FAST-NEXT: movzbl %al, %eax 701 ; FAST-NEXT: retq 702 ; 703 ; KNL-LABEL: usuboi64: 704 ; KNL: ## %bb.0: 705 ; KNL-NEXT: subq %rsi, %rdi 706 ; KNL-NEXT: setb %al 707 ; KNL-NEXT: movq %rdi, (%rdx) 708 ; KNL-NEXT: retq 709 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2) 710 %val = extractvalue {i64, i1} %t, 0 711 %obit = extractvalue {i64, i1} %t, 1 712 store i64 %val, i64* %res 713 ret i1 %obit 714 } 715 716 ; 717 ; Check the use of the overflow bit in combination with a select instruction. 718 ; 719 define i32 @saddoselecti32(i32 %v1, i32 %v2) { 720 ; SDAG-LABEL: saddoselecti32: 721 ; SDAG: ## %bb.0: 722 ; SDAG-NEXT: movl %edi, %eax 723 ; SDAG-NEXT: addl %esi, %eax 724 ; SDAG-NEXT: cmovol %edi, %esi 725 ; SDAG-NEXT: movl %esi, %eax 726 ; SDAG-NEXT: retq 727 ; 728 ; FAST-LABEL: saddoselecti32: 729 ; FAST: ## %bb.0: 730 ; FAST-NEXT: movl %edi, %eax 731 ; FAST-NEXT: addl %esi, %eax 732 ; FAST-NEXT: cmovol %edi, %esi 733 ; FAST-NEXT: movl %esi, %eax 734 ; FAST-NEXT: retq 735 ; 736 ; KNL-LABEL: saddoselecti32: 737 ; KNL: ## %bb.0: 738 ; KNL-NEXT: movl %edi, %eax 739 ; KNL-NEXT: addl %esi, %eax 740 ; KNL-NEXT: cmovol %edi, %esi 741 ; KNL-NEXT: movl %esi, %eax 742 ; KNL-NEXT: retq 743 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2) 744 %obit = extractvalue {i32, i1} %t, 1 745 %ret = select i1 %obit, i32 %v1, i32 %v2 746 ret i32 %ret 747 } 748 749 define i64 @saddoselecti64(i64 %v1, i64 %v2) { 750 ; SDAG-LABEL: saddoselecti64: 751 ; SDAG: ## %bb.0: 752 ; SDAG-NEXT: movq %rdi, %rax 753 ; SDAG-NEXT: addq %rsi, %rax 754 ; SDAG-NEXT: cmovoq %rdi, %rsi 755 ; SDAG-NEXT: movq %rsi, %rax 756 ; SDAG-NEXT: retq 757 ; 758 ; FAST-LABEL: saddoselecti64: 759 ; FAST: ## %bb.0: 760 ; FAST-NEXT: movq %rdi, %rax 761 ; FAST-NEXT: addq %rsi, %rax 762 ; FAST-NEXT: cmovoq %rdi, %rsi 763 ; FAST-NEXT: movq %rsi, %rax 764 ; FAST-NEXT: retq 765 ; 766 ; KNL-LABEL: saddoselecti64: 767 ; KNL: ## %bb.0: 768 ; KNL-NEXT: movq %rdi, %rax 769 ; KNL-NEXT: addq %rsi, %rax 770 ; KNL-NEXT: cmovoq %rdi, %rsi 771 ; KNL-NEXT: movq %rsi, %rax 772 ; KNL-NEXT: retq 773 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2) 774 %obit = extractvalue {i64, i1} %t, 1 775 %ret = select i1 %obit, i64 %v1, i64 %v2 776 ret i64 %ret 777 } 778 779 define i32 @uaddoselecti32(i32 %v1, i32 %v2) { 780 ; SDAG-LABEL: uaddoselecti32: 781 ; SDAG: ## %bb.0: 782 ; SDAG-NEXT: movl %edi, %eax 783 ; SDAG-NEXT: addl %esi, %eax 784 ; SDAG-NEXT: cmovbl %edi, %esi 785 ; SDAG-NEXT: movl %esi, %eax 786 ; SDAG-NEXT: retq 787 ; 788 ; FAST-LABEL: uaddoselecti32: 789 ; FAST: ## %bb.0: 790 ; FAST-NEXT: movl %edi, %eax 791 ; FAST-NEXT: addl %esi, %eax 792 ; FAST-NEXT: cmovbl %edi, %esi 793 ; FAST-NEXT: movl %esi, %eax 794 ; FAST-NEXT: retq 795 ; 796 ; KNL-LABEL: uaddoselecti32: 797 ; KNL: ## %bb.0: 798 ; KNL-NEXT: movl %edi, %eax 799 ; KNL-NEXT: addl %esi, %eax 800 ; KNL-NEXT: cmovbl %edi, %esi 801 ; KNL-NEXT: movl %esi, %eax 802 ; KNL-NEXT: retq 803 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2) 804 %obit = extractvalue {i32, i1} %t, 1 805 %ret = select i1 %obit, i32 %v1, i32 %v2 806 ret i32 %ret 807 } 808 809 define i64 @uaddoselecti64(i64 %v1, i64 %v2) { 810 ; SDAG-LABEL: uaddoselecti64: 811 ; SDAG: ## %bb.0: 812 ; SDAG-NEXT: movq %rdi, %rax 813 ; SDAG-NEXT: addq %rsi, %rax 814 ; SDAG-NEXT: cmovbq %rdi, %rsi 815 ; SDAG-NEXT: movq %rsi, %rax 816 ; SDAG-NEXT: retq 817 ; 818 ; FAST-LABEL: uaddoselecti64: 819 ; FAST: ## %bb.0: 820 ; FAST-NEXT: movq %rdi, %rax 821 ; FAST-NEXT: addq %rsi, %rax 822 ; FAST-NEXT: cmovbq %rdi, %rsi 823 ; FAST-NEXT: movq %rsi, %rax 824 ; FAST-NEXT: retq 825 ; 826 ; KNL-LABEL: uaddoselecti64: 827 ; KNL: ## %bb.0: 828 ; KNL-NEXT: movq %rdi, %rax 829 ; KNL-NEXT: addq %rsi, %rax 830 ; KNL-NEXT: cmovbq %rdi, %rsi 831 ; KNL-NEXT: movq %rsi, %rax 832 ; KNL-NEXT: retq 833 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2) 834 %obit = extractvalue {i64, i1} %t, 1 835 %ret = select i1 %obit, i64 %v1, i64 %v2 836 ret i64 %ret 837 } 838 839 define i32 @ssuboselecti32(i32 %v1, i32 %v2) { 840 ; SDAG-LABEL: ssuboselecti32: 841 ; SDAG: ## %bb.0: 842 ; SDAG-NEXT: cmpl %esi, %edi 843 ; SDAG-NEXT: cmovol %edi, %esi 844 ; SDAG-NEXT: movl %esi, %eax 845 ; SDAG-NEXT: retq 846 ; 847 ; FAST-LABEL: ssuboselecti32: 848 ; FAST: ## %bb.0: 849 ; FAST-NEXT: cmpl %esi, %edi 850 ; FAST-NEXT: cmovol %edi, %esi 851 ; FAST-NEXT: movl %esi, %eax 852 ; FAST-NEXT: retq 853 ; 854 ; KNL-LABEL: ssuboselecti32: 855 ; KNL: ## %bb.0: 856 ; KNL-NEXT: cmpl %esi, %edi 857 ; KNL-NEXT: cmovol %edi, %esi 858 ; KNL-NEXT: movl %esi, %eax 859 ; KNL-NEXT: retq 860 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2) 861 %obit = extractvalue {i32, i1} %t, 1 862 %ret = select i1 %obit, i32 %v1, i32 %v2 863 ret i32 %ret 864 } 865 866 define i64 @ssuboselecti64(i64 %v1, i64 %v2) { 867 ; SDAG-LABEL: ssuboselecti64: 868 ; SDAG: ## %bb.0: 869 ; SDAG-NEXT: cmpq %rsi, %rdi 870 ; SDAG-NEXT: cmovoq %rdi, %rsi 871 ; SDAG-NEXT: movq %rsi, %rax 872 ; SDAG-NEXT: retq 873 ; 874 ; FAST-LABEL: ssuboselecti64: 875 ; FAST: ## %bb.0: 876 ; FAST-NEXT: cmpq %rsi, %rdi 877 ; FAST-NEXT: cmovoq %rdi, %rsi 878 ; FAST-NEXT: movq %rsi, %rax 879 ; FAST-NEXT: retq 880 ; 881 ; KNL-LABEL: ssuboselecti64: 882 ; KNL: ## %bb.0: 883 ; KNL-NEXT: cmpq %rsi, %rdi 884 ; KNL-NEXT: cmovoq %rdi, %rsi 885 ; KNL-NEXT: movq %rsi, %rax 886 ; KNL-NEXT: retq 887 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2) 888 %obit = extractvalue {i64, i1} %t, 1 889 %ret = select i1 %obit, i64 %v1, i64 %v2 890 ret i64 %ret 891 } 892 893 define i32 @usuboselecti32(i32 %v1, i32 %v2) { 894 ; SDAG-LABEL: usuboselecti32: 895 ; SDAG: ## %bb.0: 896 ; SDAG-NEXT: cmpl %esi, %edi 897 ; SDAG-NEXT: cmovbl %edi, %esi 898 ; SDAG-NEXT: movl %esi, %eax 899 ; SDAG-NEXT: retq 900 ; 901 ; FAST-LABEL: usuboselecti32: 902 ; FAST: ## %bb.0: 903 ; FAST-NEXT: cmpl %esi, %edi 904 ; FAST-NEXT: cmovbl %edi, %esi 905 ; FAST-NEXT: movl %esi, %eax 906 ; FAST-NEXT: retq 907 ; 908 ; KNL-LABEL: usuboselecti32: 909 ; KNL: ## %bb.0: 910 ; KNL-NEXT: cmpl %esi, %edi 911 ; KNL-NEXT: cmovbl %edi, %esi 912 ; KNL-NEXT: movl %esi, %eax 913 ; KNL-NEXT: retq 914 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2) 915 %obit = extractvalue {i32, i1} %t, 1 916 %ret = select i1 %obit, i32 %v1, i32 %v2 917 ret i32 %ret 918 } 919 920 define i64 @usuboselecti64(i64 %v1, i64 %v2) { 921 ; SDAG-LABEL: usuboselecti64: 922 ; SDAG: ## %bb.0: 923 ; SDAG-NEXT: cmpq %rsi, %rdi 924 ; SDAG-NEXT: cmovbq %rdi, %rsi 925 ; SDAG-NEXT: movq %rsi, %rax 926 ; SDAG-NEXT: retq 927 ; 928 ; FAST-LABEL: usuboselecti64: 929 ; FAST: ## %bb.0: 930 ; FAST-NEXT: cmpq %rsi, %rdi 931 ; FAST-NEXT: cmovbq %rdi, %rsi 932 ; FAST-NEXT: movq %rsi, %rax 933 ; FAST-NEXT: retq 934 ; 935 ; KNL-LABEL: usuboselecti64: 936 ; KNL: ## %bb.0: 937 ; KNL-NEXT: cmpq %rsi, %rdi 938 ; KNL-NEXT: cmovbq %rdi, %rsi 939 ; KNL-NEXT: movq %rsi, %rax 940 ; KNL-NEXT: retq 941 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2) 942 %obit = extractvalue {i64, i1} %t, 1 943 %ret = select i1 %obit, i64 %v1, i64 %v2 944 ret i64 %ret 945 } 946 947 ; 948 ; Check the use of the overflow bit in combination with a branch instruction. 949 ; 950 define zeroext i1 @saddobri32(i32 %v1, i32 %v2) { 951 ; SDAG-LABEL: saddobri32: 952 ; SDAG: ## %bb.0: 953 ; SDAG-NEXT: addl %esi, %edi 954 ; SDAG-NEXT: jo LBB31_1 955 ; SDAG-NEXT: ## %bb.2: ## %continue 956 ; SDAG-NEXT: movb $1, %al 957 ; SDAG-NEXT: retq 958 ; SDAG-NEXT: LBB31_1: ## %overflow 959 ; SDAG-NEXT: xorl %eax, %eax 960 ; SDAG-NEXT: retq 961 ; 962 ; FAST-LABEL: saddobri32: 963 ; FAST: ## %bb.0: 964 ; FAST-NEXT: addl %esi, %edi 965 ; FAST-NEXT: jo LBB31_1 966 ; FAST-NEXT: ## %bb.2: ## %continue 967 ; FAST-NEXT: movb $1, %al 968 ; FAST-NEXT: andb $1, %al 969 ; FAST-NEXT: movzbl %al, %eax 970 ; FAST-NEXT: retq 971 ; FAST-NEXT: LBB31_1: ## %overflow 972 ; FAST-NEXT: xorl %eax, %eax 973 ; FAST-NEXT: andb $1, %al 974 ; FAST-NEXT: movzbl %al, %eax 975 ; FAST-NEXT: retq 976 ; 977 ; KNL-LABEL: saddobri32: 978 ; KNL: ## %bb.0: 979 ; KNL-NEXT: addl %esi, %edi 980 ; KNL-NEXT: jo LBB31_1 981 ; KNL-NEXT: ## %bb.2: ## %continue 982 ; KNL-NEXT: movb $1, %al 983 ; KNL-NEXT: retq 984 ; KNL-NEXT: LBB31_1: ## %overflow 985 ; KNL-NEXT: xorl %eax, %eax 986 ; KNL-NEXT: retq 987 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2) 988 %val = extractvalue {i32, i1} %t, 0 989 %obit = extractvalue {i32, i1} %t, 1 990 br i1 %obit, label %overflow, label %continue, !prof !0 991 992 overflow: 993 ret i1 false 994 995 continue: 996 ret i1 true 997 } 998 999 define zeroext i1 @saddobri64(i64 %v1, i64 %v2) { 1000 ; SDAG-LABEL: saddobri64: 1001 ; SDAG: ## %bb.0: 1002 ; SDAG-NEXT: addq %rsi, %rdi 1003 ; SDAG-NEXT: jo LBB32_1 1004 ; SDAG-NEXT: ## %bb.2: ## %continue 1005 ; SDAG-NEXT: movb $1, %al 1006 ; SDAG-NEXT: retq 1007 ; SDAG-NEXT: LBB32_1: ## %overflow 1008 ; SDAG-NEXT: xorl %eax, %eax 1009 ; SDAG-NEXT: retq 1010 ; 1011 ; FAST-LABEL: saddobri64: 1012 ; FAST: ## %bb.0: 1013 ; FAST-NEXT: addq %rsi, %rdi 1014 ; FAST-NEXT: jo LBB32_1 1015 ; FAST-NEXT: ## %bb.2: ## %continue 1016 ; FAST-NEXT: movb $1, %al 1017 ; FAST-NEXT: andb $1, %al 1018 ; FAST-NEXT: movzbl %al, %eax 1019 ; FAST-NEXT: retq 1020 ; FAST-NEXT: LBB32_1: ## %overflow 1021 ; FAST-NEXT: xorl %eax, %eax 1022 ; FAST-NEXT: andb $1, %al 1023 ; FAST-NEXT: movzbl %al, %eax 1024 ; FAST-NEXT: retq 1025 ; 1026 ; KNL-LABEL: saddobri64: 1027 ; KNL: ## %bb.0: 1028 ; KNL-NEXT: addq %rsi, %rdi 1029 ; KNL-NEXT: jo LBB32_1 1030 ; KNL-NEXT: ## %bb.2: ## %continue 1031 ; KNL-NEXT: movb $1, %al 1032 ; KNL-NEXT: retq 1033 ; KNL-NEXT: LBB32_1: ## %overflow 1034 ; KNL-NEXT: xorl %eax, %eax 1035 ; KNL-NEXT: retq 1036 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2) 1037 %val = extractvalue {i64, i1} %t, 0 1038 %obit = extractvalue {i64, i1} %t, 1 1039 br i1 %obit, label %overflow, label %continue, !prof !0 1040 1041 overflow: 1042 ret i1 false 1043 1044 continue: 1045 ret i1 true 1046 } 1047 1048 define zeroext i1 @uaddobri32(i32 %v1, i32 %v2) { 1049 ; SDAG-LABEL: uaddobri32: 1050 ; SDAG: ## %bb.0: 1051 ; SDAG-NEXT: addl %esi, %edi 1052 ; SDAG-NEXT: jb LBB33_1 1053 ; SDAG-NEXT: ## %bb.2: ## %continue 1054 ; SDAG-NEXT: movb $1, %al 1055 ; SDAG-NEXT: retq 1056 ; SDAG-NEXT: LBB33_1: ## %overflow 1057 ; SDAG-NEXT: xorl %eax, %eax 1058 ; SDAG-NEXT: retq 1059 ; 1060 ; FAST-LABEL: uaddobri32: 1061 ; FAST: ## %bb.0: 1062 ; FAST-NEXT: addl %esi, %edi 1063 ; FAST-NEXT: jb LBB33_1 1064 ; FAST-NEXT: ## %bb.2: ## %continue 1065 ; FAST-NEXT: movb $1, %al 1066 ; FAST-NEXT: andb $1, %al 1067 ; FAST-NEXT: movzbl %al, %eax 1068 ; FAST-NEXT: retq 1069 ; FAST-NEXT: LBB33_1: ## %overflow 1070 ; FAST-NEXT: xorl %eax, %eax 1071 ; FAST-NEXT: andb $1, %al 1072 ; FAST-NEXT: movzbl %al, %eax 1073 ; FAST-NEXT: retq 1074 ; 1075 ; KNL-LABEL: uaddobri32: 1076 ; KNL: ## %bb.0: 1077 ; KNL-NEXT: addl %esi, %edi 1078 ; KNL-NEXT: jb LBB33_1 1079 ; KNL-NEXT: ## %bb.2: ## %continue 1080 ; KNL-NEXT: movb $1, %al 1081 ; KNL-NEXT: retq 1082 ; KNL-NEXT: LBB33_1: ## %overflow 1083 ; KNL-NEXT: xorl %eax, %eax 1084 ; KNL-NEXT: retq 1085 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2) 1086 %val = extractvalue {i32, i1} %t, 0 1087 %obit = extractvalue {i32, i1} %t, 1 1088 br i1 %obit, label %overflow, label %continue, !prof !0 1089 1090 overflow: 1091 ret i1 false 1092 1093 continue: 1094 ret i1 true 1095 } 1096 1097 define zeroext i1 @uaddobri64(i64 %v1, i64 %v2) { 1098 ; SDAG-LABEL: uaddobri64: 1099 ; SDAG: ## %bb.0: 1100 ; SDAG-NEXT: addq %rsi, %rdi 1101 ; SDAG-NEXT: jb LBB34_1 1102 ; SDAG-NEXT: ## %bb.2: ## %continue 1103 ; SDAG-NEXT: movb $1, %al 1104 ; SDAG-NEXT: retq 1105 ; SDAG-NEXT: LBB34_1: ## %overflow 1106 ; SDAG-NEXT: xorl %eax, %eax 1107 ; SDAG-NEXT: retq 1108 ; 1109 ; FAST-LABEL: uaddobri64: 1110 ; FAST: ## %bb.0: 1111 ; FAST-NEXT: addq %rsi, %rdi 1112 ; FAST-NEXT: jb LBB34_1 1113 ; FAST-NEXT: ## %bb.2: ## %continue 1114 ; FAST-NEXT: movb $1, %al 1115 ; FAST-NEXT: andb $1, %al 1116 ; FAST-NEXT: movzbl %al, %eax 1117 ; FAST-NEXT: retq 1118 ; FAST-NEXT: LBB34_1: ## %overflow 1119 ; FAST-NEXT: xorl %eax, %eax 1120 ; FAST-NEXT: andb $1, %al 1121 ; FAST-NEXT: movzbl %al, %eax 1122 ; FAST-NEXT: retq 1123 ; 1124 ; KNL-LABEL: uaddobri64: 1125 ; KNL: ## %bb.0: 1126 ; KNL-NEXT: addq %rsi, %rdi 1127 ; KNL-NEXT: jb LBB34_1 1128 ; KNL-NEXT: ## %bb.2: ## %continue 1129 ; KNL-NEXT: movb $1, %al 1130 ; KNL-NEXT: retq 1131 ; KNL-NEXT: LBB34_1: ## %overflow 1132 ; KNL-NEXT: xorl %eax, %eax 1133 ; KNL-NEXT: retq 1134 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2) 1135 %val = extractvalue {i64, i1} %t, 0 1136 %obit = extractvalue {i64, i1} %t, 1 1137 br i1 %obit, label %overflow, label %continue, !prof !0 1138 1139 overflow: 1140 ret i1 false 1141 1142 continue: 1143 ret i1 true 1144 } 1145 1146 define zeroext i1 @ssubobri32(i32 %v1, i32 %v2) { 1147 ; SDAG-LABEL: ssubobri32: 1148 ; SDAG: ## %bb.0: 1149 ; SDAG-NEXT: cmpl %esi, %edi 1150 ; SDAG-NEXT: jo LBB35_1 1151 ; SDAG-NEXT: ## %bb.2: ## %continue 1152 ; SDAG-NEXT: movb $1, %al 1153 ; SDAG-NEXT: retq 1154 ; SDAG-NEXT: LBB35_1: ## %overflow 1155 ; SDAG-NEXT: xorl %eax, %eax 1156 ; SDAG-NEXT: retq 1157 ; 1158 ; FAST-LABEL: ssubobri32: 1159 ; FAST: ## %bb.0: 1160 ; FAST-NEXT: cmpl %esi, %edi 1161 ; FAST-NEXT: jo LBB35_1 1162 ; FAST-NEXT: ## %bb.2: ## %continue 1163 ; FAST-NEXT: movb $1, %al 1164 ; FAST-NEXT: andb $1, %al 1165 ; FAST-NEXT: movzbl %al, %eax 1166 ; FAST-NEXT: retq 1167 ; FAST-NEXT: LBB35_1: ## %overflow 1168 ; FAST-NEXT: xorl %eax, %eax 1169 ; FAST-NEXT: andb $1, %al 1170 ; FAST-NEXT: movzbl %al, %eax 1171 ; FAST-NEXT: retq 1172 ; 1173 ; KNL-LABEL: ssubobri32: 1174 ; KNL: ## %bb.0: 1175 ; KNL-NEXT: cmpl %esi, %edi 1176 ; KNL-NEXT: jo LBB35_1 1177 ; KNL-NEXT: ## %bb.2: ## %continue 1178 ; KNL-NEXT: movb $1, %al 1179 ; KNL-NEXT: retq 1180 ; KNL-NEXT: LBB35_1: ## %overflow 1181 ; KNL-NEXT: xorl %eax, %eax 1182 ; KNL-NEXT: retq 1183 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2) 1184 %val = extractvalue {i32, i1} %t, 0 1185 %obit = extractvalue {i32, i1} %t, 1 1186 br i1 %obit, label %overflow, label %continue, !prof !0 1187 1188 overflow: 1189 ret i1 false 1190 1191 continue: 1192 ret i1 true 1193 } 1194 1195 define zeroext i1 @ssubobri64(i64 %v1, i64 %v2) { 1196 ; SDAG-LABEL: ssubobri64: 1197 ; SDAG: ## %bb.0: 1198 ; SDAG-NEXT: cmpq %rsi, %rdi 1199 ; SDAG-NEXT: jo LBB36_1 1200 ; SDAG-NEXT: ## %bb.2: ## %continue 1201 ; SDAG-NEXT: movb $1, %al 1202 ; SDAG-NEXT: retq 1203 ; SDAG-NEXT: LBB36_1: ## %overflow 1204 ; SDAG-NEXT: xorl %eax, %eax 1205 ; SDAG-NEXT: retq 1206 ; 1207 ; FAST-LABEL: ssubobri64: 1208 ; FAST: ## %bb.0: 1209 ; FAST-NEXT: cmpq %rsi, %rdi 1210 ; FAST-NEXT: jo LBB36_1 1211 ; FAST-NEXT: ## %bb.2: ## %continue 1212 ; FAST-NEXT: movb $1, %al 1213 ; FAST-NEXT: andb $1, %al 1214 ; FAST-NEXT: movzbl %al, %eax 1215 ; FAST-NEXT: retq 1216 ; FAST-NEXT: LBB36_1: ## %overflow 1217 ; FAST-NEXT: xorl %eax, %eax 1218 ; FAST-NEXT: andb $1, %al 1219 ; FAST-NEXT: movzbl %al, %eax 1220 ; FAST-NEXT: retq 1221 ; 1222 ; KNL-LABEL: ssubobri64: 1223 ; KNL: ## %bb.0: 1224 ; KNL-NEXT: cmpq %rsi, %rdi 1225 ; KNL-NEXT: jo LBB36_1 1226 ; KNL-NEXT: ## %bb.2: ## %continue 1227 ; KNL-NEXT: movb $1, %al 1228 ; KNL-NEXT: retq 1229 ; KNL-NEXT: LBB36_1: ## %overflow 1230 ; KNL-NEXT: xorl %eax, %eax 1231 ; KNL-NEXT: retq 1232 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2) 1233 %val = extractvalue {i64, i1} %t, 0 1234 %obit = extractvalue {i64, i1} %t, 1 1235 br i1 %obit, label %overflow, label %continue, !prof !0 1236 1237 overflow: 1238 ret i1 false 1239 1240 continue: 1241 ret i1 true 1242 } 1243 1244 define zeroext i1 @usubobri32(i32 %v1, i32 %v2) { 1245 ; SDAG-LABEL: usubobri32: 1246 ; SDAG: ## %bb.0: 1247 ; SDAG-NEXT: cmpl %esi, %edi 1248 ; SDAG-NEXT: jb LBB37_1 1249 ; SDAG-NEXT: ## %bb.2: ## %continue 1250 ; SDAG-NEXT: movb $1, %al 1251 ; SDAG-NEXT: retq 1252 ; SDAG-NEXT: LBB37_1: ## %overflow 1253 ; SDAG-NEXT: xorl %eax, %eax 1254 ; SDAG-NEXT: retq 1255 ; 1256 ; FAST-LABEL: usubobri32: 1257 ; FAST: ## %bb.0: 1258 ; FAST-NEXT: cmpl %esi, %edi 1259 ; FAST-NEXT: jb LBB37_1 1260 ; FAST-NEXT: ## %bb.2: ## %continue 1261 ; FAST-NEXT: movb $1, %al 1262 ; FAST-NEXT: andb $1, %al 1263 ; FAST-NEXT: movzbl %al, %eax 1264 ; FAST-NEXT: retq 1265 ; FAST-NEXT: LBB37_1: ## %overflow 1266 ; FAST-NEXT: xorl %eax, %eax 1267 ; FAST-NEXT: andb $1, %al 1268 ; FAST-NEXT: movzbl %al, %eax 1269 ; FAST-NEXT: retq 1270 ; 1271 ; KNL-LABEL: usubobri32: 1272 ; KNL: ## %bb.0: 1273 ; KNL-NEXT: cmpl %esi, %edi 1274 ; KNL-NEXT: jb LBB37_1 1275 ; KNL-NEXT: ## %bb.2: ## %continue 1276 ; KNL-NEXT: movb $1, %al 1277 ; KNL-NEXT: retq 1278 ; KNL-NEXT: LBB37_1: ## %overflow 1279 ; KNL-NEXT: xorl %eax, %eax 1280 ; KNL-NEXT: retq 1281 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2) 1282 %val = extractvalue {i32, i1} %t, 0 1283 %obit = extractvalue {i32, i1} %t, 1 1284 br i1 %obit, label %overflow, label %continue, !prof !0 1285 1286 overflow: 1287 ret i1 false 1288 1289 continue: 1290 ret i1 true 1291 } 1292 1293 define zeroext i1 @usubobri64(i64 %v1, i64 %v2) { 1294 ; SDAG-LABEL: usubobri64: 1295 ; SDAG: ## %bb.0: 1296 ; SDAG-NEXT: cmpq %rsi, %rdi 1297 ; SDAG-NEXT: jb LBB38_1 1298 ; SDAG-NEXT: ## %bb.2: ## %continue 1299 ; SDAG-NEXT: movb $1, %al 1300 ; SDAG-NEXT: retq 1301 ; SDAG-NEXT: LBB38_1: ## %overflow 1302 ; SDAG-NEXT: xorl %eax, %eax 1303 ; SDAG-NEXT: retq 1304 ; 1305 ; FAST-LABEL: usubobri64: 1306 ; FAST: ## %bb.0: 1307 ; FAST-NEXT: cmpq %rsi, %rdi 1308 ; FAST-NEXT: jb LBB38_1 1309 ; FAST-NEXT: ## %bb.2: ## %continue 1310 ; FAST-NEXT: movb $1, %al 1311 ; FAST-NEXT: andb $1, %al 1312 ; FAST-NEXT: movzbl %al, %eax 1313 ; FAST-NEXT: retq 1314 ; FAST-NEXT: LBB38_1: ## %overflow 1315 ; FAST-NEXT: xorl %eax, %eax 1316 ; FAST-NEXT: andb $1, %al 1317 ; FAST-NEXT: movzbl %al, %eax 1318 ; FAST-NEXT: retq 1319 ; 1320 ; KNL-LABEL: usubobri64: 1321 ; KNL: ## %bb.0: 1322 ; KNL-NEXT: cmpq %rsi, %rdi 1323 ; KNL-NEXT: jb LBB38_1 1324 ; KNL-NEXT: ## %bb.2: ## %continue 1325 ; KNL-NEXT: movb $1, %al 1326 ; KNL-NEXT: retq 1327 ; KNL-NEXT: LBB38_1: ## %overflow 1328 ; KNL-NEXT: xorl %eax, %eax 1329 ; KNL-NEXT: retq 1330 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2) 1331 %val = extractvalue {i64, i1} %t, 0 1332 %obit = extractvalue {i64, i1} %t, 1 1333 br i1 %obit, label %overflow, label %continue, !prof !0 1334 1335 overflow: 1336 ret i1 false 1337 1338 continue: 1339 ret i1 true 1340 } 1341 1342 define {i64, i1} @uaddoovf(i64 %a, i64 %b) { 1343 ; SDAG-LABEL: uaddoovf: 1344 ; SDAG: ## %bb.0: 1345 ; SDAG-NEXT: movzbl %dil, %ecx 1346 ; SDAG-NEXT: movzbl %sil, %eax 1347 ; SDAG-NEXT: addq %rcx, %rax 1348 ; SDAG-NEXT: xorl %edx, %edx 1349 ; SDAG-NEXT: retq 1350 ; 1351 ; FAST-LABEL: uaddoovf: 1352 ; FAST: ## %bb.0: 1353 ; FAST-NEXT: movzbl %dil, %ecx 1354 ; FAST-NEXT: movzbl %sil, %eax 1355 ; FAST-NEXT: addq %rcx, %rax 1356 ; FAST-NEXT: xorl %edx, %edx 1357 ; FAST-NEXT: retq 1358 ; 1359 ; KNL-LABEL: uaddoovf: 1360 ; KNL: ## %bb.0: 1361 ; KNL-NEXT: movzbl %dil, %ecx 1362 ; KNL-NEXT: movzbl %sil, %eax 1363 ; KNL-NEXT: addq %rcx, %rax 1364 ; KNL-NEXT: xorl %edx, %edx 1365 ; KNL-NEXT: retq 1366 %1 = and i64 %a, 255 1367 %2 = and i64 %b, 255 1368 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %1, i64 %2) 1369 ret {i64, i1} %t 1370 } 1371 1372 define {i64, i1} @usuboovf(i64 %a, i64 %b) { 1373 ; SDAG-LABEL: usuboovf: 1374 ; SDAG: ## %bb.0: 1375 ; SDAG-NEXT: notq %rsi 1376 ; SDAG-NEXT: xorl %edx, %edx 1377 ; SDAG-NEXT: movq %rsi, %rax 1378 ; SDAG-NEXT: retq 1379 ; 1380 ; FAST-LABEL: usuboovf: 1381 ; FAST: ## %bb.0: 1382 ; FAST-NEXT: notq %rsi 1383 ; FAST-NEXT: xorl %edx, %edx 1384 ; FAST-NEXT: movq %rsi, %rax 1385 ; FAST-NEXT: retq 1386 ; 1387 ; KNL-LABEL: usuboovf: 1388 ; KNL: ## %bb.0: 1389 ; KNL-NEXT: notq %rsi 1390 ; KNL-NEXT: xorl %edx, %edx 1391 ; KNL-NEXT: movq %rsi, %rax 1392 ; KNL-NEXT: retq 1393 %t0 = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %a) 1394 %v0 = extractvalue {i64, i1} %t0, 0 1395 %o0 = extractvalue {i64, i1} %t0, 1 1396 %t1 = call {i64, i1} @llvm.usub.with.overflow.i64(i64 -1, i64 %b) 1397 %v1 = extractvalue {i64, i1} %t1, 0 1398 %o1 = extractvalue {i64, i1} %t1, 1 1399 %oo = or i1 %o0, %o1 1400 %t2 = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v0) 1401 %v2 = extractvalue {i64, i1} %t2, 0 1402 %o2 = extractvalue {i64, i1} %t2, 1 1403 %ooo = or i1 %oo, %o2 1404 %t = insertvalue {i64, i1} %t2, i1 %ooo, 1 1405 ret {i64, i1} %t 1406 } 1407 1408 declare {i8, i1} @llvm.sadd.with.overflow.i8 (i8, i8 ) nounwind readnone 1409 declare {i16, i1} @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone 1410 declare {i32, i1} @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone 1411 declare {i64, i1} @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone 1412 declare {i8, i1} @llvm.uadd.with.overflow.i8 (i8, i8 ) nounwind readnone 1413 declare {i16, i1} @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone 1414 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone 1415 declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone 1416 declare {i32, i1} @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone 1417 declare {i64, i1} @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone 1418 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone 1419 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone 1420 1421 !0 = !{!"branch_weights", i32 0, i32 2147483647} 1422