1 ; RUN: opt %s -S -simplifycfg | FileCheck %s 2 3 declare void @dead() 4 declare void @alive() 5 declare void @is(i1) 6 7 ; Test same condition with swapped operands. 8 ; void test_swapped_ops(unsigned a, unsigned b) { 9 ; if (a > b) { 10 ; if (b > a) <- always false 11 ; dead(); 12 ; alive(); 13 ; } 14 ; } 15 ; 16 ; CHECK-LABEL: @test_swapped_ops 17 ; CHECK-NOT: call void @dead() 18 ; CHECK: call void @alive() 19 ; CHECK: ret 20 define void @test_swapped_ops(i32 %a, i32 %b) { 21 entry: 22 %cmp = icmp ugt i32 %a, %b 23 br i1 %cmp, label %if.then, label %if.end3 24 25 if.then: 26 %cmp1 = icmp ugt i32 %b, %a 27 br i1 %cmp1, label %if.then2, label %if.end 28 29 if.then2: 30 call void @dead() 31 br label %if.end 32 33 if.end: 34 call void @alive() 35 br label %if.end3 36 37 if.end3: 38 ret void 39 } 40 41 ; void test_swapped_pred(unsigned a, unsigned b) { 42 ; if (a > b) { 43 ; alive(); 44 ; if (b < a) <- always true; remove branch 45 ; alive(); 46 ; } 47 ; } 48 ; 49 ; CHECK-LABEL: @test_swapped_pred 50 ; CHECK: call void @alive() 51 ; CHECK-NEXT: call void @alive() 52 ; CHECK: ret 53 define void @test_swapped_pred(i32 %a, i32 %b) { 54 entry: 55 %cmp = icmp ugt i32 %a, %b 56 br i1 %cmp, label %if.then, label %if.end3 57 58 if.then: 59 call void @alive() 60 %cmp1 = icmp ult i32 %b, %a 61 br i1 %cmp1, label %if.then2, label %if.end3 62 63 if.then2: 64 call void @alive() 65 br label %if.end3 66 67 if.end3: 68 ret void 69 } 70 71 ; A == B implies A == B is true. 72 ; CHECK-LABEL: @test_eq_eq 73 ; CHECK: call void @is(i1 true) 74 ; CHECK-NOT: call void @is(i1 false) 75 define void @test_eq_eq(i32 %a, i32 %b) { 76 %cmp1 = icmp eq i32 %a, %b 77 br i1 %cmp1, label %taken, label %untaken 78 79 taken: 80 %cmp2 = icmp eq i32 %a, %b 81 br i1 %cmp2, label %eq_eq_istrue, label %eq_eq_isfalse 82 83 eq_eq_istrue: 84 call void @is(i1 true) 85 ret void 86 87 eq_eq_isfalse: 88 call void @is(i1 false) 89 ret void 90 91 untaken: 92 ret void 93 } 94 95 ; A == B implies A != B is false. 96 ; CHECK-LABEL: @test_eq_ne 97 ; CHECK-NOT: call void @is(i1 true) 98 ; CHECK: call void @is(i1 false) 99 define void @test_eq_ne(i32 %a, i32 %b) { 100 %cmp1 = icmp eq i32 %a, %b 101 br i1 %cmp1, label %taken, label %untaken 102 103 taken: 104 %cmp2 = icmp ne i32 %a, %b 105 br i1 %cmp2, label %eq_ne_istrue, label %eq_ne_isfalse 106 107 eq_ne_istrue: 108 call void @is(i1 true) 109 ret void 110 111 eq_ne_isfalse: 112 call void @is(i1 false) 113 ret void 114 115 untaken: 116 ret void 117 } 118 119 ; A == B implies A >u B is false. 120 ; CHECK-LABEL: @test_eq_ugt 121 ; CHECK-NOT: call void @is(i1 true) 122 ; CHECK: call void @is(i1 false) 123 define void @test_eq_ugt(i32 %a, i32 %b) { 124 %cmp1 = icmp eq i32 %a, %b 125 br i1 %cmp1, label %taken, label %untaken 126 127 taken: 128 %cmp2 = icmp ugt i32 %a, %b 129 br i1 %cmp2, label %eq_ugt_istrue, label %eq_ugt_isfalse 130 131 eq_ugt_istrue: 132 call void @is(i1 true) 133 ret void 134 135 eq_ugt_isfalse: 136 call void @is(i1 false) 137 ret void 138 139 untaken: 140 ret void 141 } 142 143 ; A == B implies A >=u B is true. 144 ; CHECK-LABEL: @test_eq_uge 145 ; CHECK: call void @is(i1 true) 146 ; CHECK-NOT: call void @is(i1 false) 147 define void @test_eq_uge(i32 %a, i32 %b) { 148 %cmp1 = icmp eq i32 %a, %b 149 br i1 %cmp1, label %taken, label %untaken 150 151 taken: 152 %cmp2 = icmp uge i32 %a, %b 153 br i1 %cmp2, label %eq_uge_istrue, label %eq_uge_isfalse 154 155 eq_uge_istrue: 156 call void @is(i1 true) 157 ret void 158 159 eq_uge_isfalse: 160 call void @is(i1 false) 161 ret void 162 163 untaken: 164 ret void 165 } 166 167 ; A == B implies A <u B is false. 168 ; CHECK-LABEL: @test_eq_ult 169 ; CHECK-NOT: call void @is(i1 true) 170 ; CHECK: call void @is(i1 false) 171 define void @test_eq_ult(i32 %a, i32 %b) { 172 %cmp1 = icmp eq i32 %a, %b 173 br i1 %cmp1, label %taken, label %untaken 174 175 taken: 176 %cmp2 = icmp ult i32 %a, %b 177 br i1 %cmp2, label %eq_ult_istrue, label %eq_ult_isfalse 178 179 eq_ult_istrue: 180 call void @is(i1 true) 181 ret void 182 183 eq_ult_isfalse: 184 call void @is(i1 false) 185 ret void 186 187 untaken: 188 ret void 189 } 190 191 ; A == B implies A <=u B is true. 192 ; CHECK-LABEL: @test_eq_ule 193 ; CHECK: call void @is(i1 true) 194 ; CHECK-NOT: call void @is(i1 false) 195 define void @test_eq_ule(i32 %a, i32 %b) { 196 %cmp1 = icmp eq i32 %a, %b 197 br i1 %cmp1, label %taken, label %untaken 198 199 taken: 200 %cmp2 = icmp ule i32 %a, %b 201 br i1 %cmp2, label %eq_ule_istrue, label %eq_ule_isfalse 202 203 eq_ule_istrue: 204 call void @is(i1 true) 205 ret void 206 207 eq_ule_isfalse: 208 call void @is(i1 false) 209 ret void 210 211 untaken: 212 ret void 213 } 214 215 ; A == B implies A >s B is false. 216 ; CHECK-LABEL: @test_eq_sgt 217 ; CHECK-NOT: call void @is(i1 true) 218 ; CHECK: call void @is(i1 false) 219 define void @test_eq_sgt(i32 %a, i32 %b) { 220 %cmp1 = icmp eq i32 %a, %b 221 br i1 %cmp1, label %taken, label %untaken 222 223 taken: 224 %cmp2 = icmp sgt i32 %a, %b 225 br i1 %cmp2, label %eq_sgt_istrue, label %eq_sgt_isfalse 226 227 eq_sgt_istrue: 228 call void @is(i1 true) 229 ret void 230 231 eq_sgt_isfalse: 232 call void @is(i1 false) 233 ret void 234 235 untaken: 236 ret void 237 } 238 239 ; A == B implies A >=s B is true. 240 ; CHECK-LABEL: @test_eq_sge 241 ; CHECK: call void @is(i1 true) 242 ; CHECK-NOT: call void @is(i1 false) 243 define void @test_eq_sge(i32 %a, i32 %b) { 244 %cmp1 = icmp eq i32 %a, %b 245 br i1 %cmp1, label %taken, label %untaken 246 247 taken: 248 %cmp2 = icmp sge i32 %a, %b 249 br i1 %cmp2, label %eq_sge_istrue, label %eq_sge_isfalse 250 251 eq_sge_istrue: 252 call void @is(i1 true) 253 ret void 254 255 eq_sge_isfalse: 256 call void @is(i1 false) 257 ret void 258 259 untaken: 260 ret void 261 } 262 263 ; A == B implies A <s B is false. 264 ; CHECK-LABEL: @test_eq_slt 265 ; CHECK-NOT: call void @is(i1 true) 266 ; CHECK: call void @is(i1 false) 267 define void @test_eq_slt(i32 %a, i32 %b) { 268 %cmp1 = icmp eq i32 %a, %b 269 br i1 %cmp1, label %taken, label %untaken 270 271 taken: 272 %cmp2 = icmp slt i32 %a, %b 273 br i1 %cmp2, label %eq_slt_istrue, label %eq_slt_isfalse 274 275 eq_slt_istrue: 276 call void @is(i1 true) 277 ret void 278 279 eq_slt_isfalse: 280 call void @is(i1 false) 281 ret void 282 283 untaken: 284 ret void 285 } 286 287 ; A == B implies A <=s B is true. 288 ; CHECK-LABEL: @test_eq_sle 289 ; CHECK: call void @is(i1 true) 290 ; CHECK-NOT: call void @is(i1 false) 291 define void @test_eq_sle(i32 %a, i32 %b) { 292 %cmp1 = icmp eq i32 %a, %b 293 br i1 %cmp1, label %taken, label %untaken 294 295 taken: 296 %cmp2 = icmp sle i32 %a, %b 297 br i1 %cmp2, label %eq_sle_istrue, label %eq_sle_isfalse 298 299 eq_sle_istrue: 300 call void @is(i1 true) 301 ret void 302 303 eq_sle_isfalse: 304 call void @is(i1 false) 305 ret void 306 307 untaken: 308 ret void 309 } 310 311 ; A != B implies A != B is true. 312 ; CHECK-LABEL: @test_ne_ne 313 ; CHECK: call void @is(i1 true) 314 ; CHECK-NOT: call void @is(i1 false) 315 define void @test_ne_ne(i32 %a, i32 %b) { 316 %cmp1 = icmp ne i32 %a, %b 317 br i1 %cmp1, label %taken, label %untaken 318 319 taken: 320 %cmp2 = icmp ne i32 %a, %b 321 br i1 %cmp2, label %ne_ne_istrue, label %ne_ne_isfalse 322 323 ne_ne_istrue: 324 call void @is(i1 true) 325 ret void 326 327 ne_ne_isfalse: 328 call void @is(i1 false) 329 ret void 330 331 untaken: 332 ret void 333 } 334 335 ; A != B implies A >u B is unknown to be true or false. 336 ; CHECK-LABEL: @test_ne_ugt 337 ; CHECK: call void @is(i1 true) 338 ; CHECK: call void @is(i1 false) 339 define void @test_ne_ugt(i32 %a, i32 %b) { 340 %cmp1 = icmp ne i32 %a, %b 341 br i1 %cmp1, label %taken, label %untaken 342 343 taken: 344 %cmp2 = icmp ugt i32 %a, %b 345 br i1 %cmp2, label %ne_ugt_istrue, label %ne_ugt_isfalse 346 347 ne_ugt_istrue: 348 call void @is(i1 true) 349 ret void 350 351 ne_ugt_isfalse: 352 call void @is(i1 false) 353 ret void 354 355 untaken: 356 ret void 357 } 358 359 ; A != B implies A >=u B is unknown to be true or false. 360 ; CHECK-LABEL: @test_ne_uge 361 ; CHECK: call void @is(i1 true) 362 ; CHECK: call void @is(i1 false) 363 define void @test_ne_uge(i32 %a, i32 %b) { 364 %cmp1 = icmp ne i32 %a, %b 365 br i1 %cmp1, label %taken, label %untaken 366 367 taken: 368 %cmp2 = icmp uge i32 %a, %b 369 br i1 %cmp2, label %ne_uge_istrue, label %ne_uge_isfalse 370 371 ne_uge_istrue: 372 call void @is(i1 true) 373 ret void 374 375 ne_uge_isfalse: 376 call void @is(i1 false) 377 ret void 378 379 untaken: 380 ret void 381 } 382 383 ; A != B implies A <u B is unknown to be true or false. 384 ; CHECK-LABEL: @test_ne_ult 385 ; CHECK: call void @is(i1 true) 386 ; CHECK: call void @is(i1 false) 387 define void @test_ne_ult(i32 %a, i32 %b) { 388 %cmp1 = icmp ne i32 %a, %b 389 br i1 %cmp1, label %taken, label %untaken 390 391 taken: 392 %cmp2 = icmp ult i32 %a, %b 393 br i1 %cmp2, label %ne_ult_istrue, label %ne_ult_isfalse 394 395 ne_ult_istrue: 396 call void @is(i1 true) 397 ret void 398 399 ne_ult_isfalse: 400 call void @is(i1 false) 401 ret void 402 403 untaken: 404 ret void 405 } 406 407 ; A != B implies A <=u B is unknown to be true or false. 408 ; CHECK-LABEL: @test_ne_ule 409 ; CHECK: call void @is(i1 true) 410 ; CHECK: call void @is(i1 false) 411 define void @test_ne_ule(i32 %a, i32 %b) { 412 %cmp1 = icmp ne i32 %a, %b 413 br i1 %cmp1, label %taken, label %untaken 414 415 taken: 416 %cmp2 = icmp ule i32 %a, %b 417 br i1 %cmp2, label %ne_ule_istrue, label %ne_ule_isfalse 418 419 ne_ule_istrue: 420 call void @is(i1 true) 421 ret void 422 423 ne_ule_isfalse: 424 call void @is(i1 false) 425 ret void 426 427 untaken: 428 ret void 429 } 430 431 ; A != B implies A >s B is unknown to be true or false. 432 ; CHECK-LABEL: @test_ne_sgt 433 ; CHECK: call void @is(i1 true) 434 ; CHECK: call void @is(i1 false) 435 define void @test_ne_sgt(i32 %a, i32 %b) { 436 %cmp1 = icmp ne i32 %a, %b 437 br i1 %cmp1, label %taken, label %untaken 438 439 taken: 440 %cmp2 = icmp sgt i32 %a, %b 441 br i1 %cmp2, label %ne_sgt_istrue, label %ne_sgt_isfalse 442 443 ne_sgt_istrue: 444 call void @is(i1 true) 445 ret void 446 447 ne_sgt_isfalse: 448 call void @is(i1 false) 449 ret void 450 451 untaken: 452 ret void 453 } 454 455 ; A != B implies A >=s B is unknown to be true or false. 456 ; CHECK-LABEL: @test_ne_sge 457 ; CHECK: call void @is(i1 true) 458 ; CHECK: call void @is(i1 false) 459 define void @test_ne_sge(i32 %a, i32 %b) { 460 %cmp1 = icmp ne i32 %a, %b 461 br i1 %cmp1, label %taken, label %untaken 462 463 taken: 464 %cmp2 = icmp sge i32 %a, %b 465 br i1 %cmp2, label %ne_sge_istrue, label %ne_sge_isfalse 466 467 ne_sge_istrue: 468 call void @is(i1 true) 469 ret void 470 471 ne_sge_isfalse: 472 call void @is(i1 false) 473 ret void 474 475 untaken: 476 ret void 477 } 478 479 ; A != B implies A <s B is unknown to be true or false. 480 ; CHECK-LABEL: @test_ne_slt 481 ; CHECK: call void @is(i1 true) 482 ; CHECK: call void @is(i1 false) 483 define void @test_ne_slt(i32 %a, i32 %b) { 484 %cmp1 = icmp ne i32 %a, %b 485 br i1 %cmp1, label %taken, label %untaken 486 487 taken: 488 %cmp2 = icmp slt i32 %a, %b 489 br i1 %cmp2, label %ne_slt_istrue, label %ne_slt_isfalse 490 491 ne_slt_istrue: 492 call void @is(i1 true) 493 ret void 494 495 ne_slt_isfalse: 496 call void @is(i1 false) 497 ret void 498 499 untaken: 500 ret void 501 } 502 503 ; A != B implies A <=s B is unknown to be true or false. 504 ; CHECK-LABEL: @test_ne_sle 505 ; CHECK: call void @is(i1 true) 506 ; CHECK: call void @is(i1 false) 507 define void @test_ne_sle(i32 %a, i32 %b) { 508 %cmp1 = icmp ne i32 %a, %b 509 br i1 %cmp1, label %taken, label %untaken 510 511 taken: 512 %cmp2 = icmp sle i32 %a, %b 513 br i1 %cmp2, label %ne_sle_istrue, label %ne_sle_isfalse 514 515 ne_sle_istrue: 516 call void @is(i1 true) 517 ret void 518 519 ne_sle_isfalse: 520 call void @is(i1 false) 521 ret void 522 523 untaken: 524 ret void 525 } 526 527 ; A >u B implies A >u B is true. 528 ; CHECK-LABEL: @test_ugt_ugt 529 ; CHECK: call void @is(i1 true) 530 ; CHECK-NOT: call void @is(i1 false) 531 define void @test_ugt_ugt(i32 %a, i32 %b) { 532 %cmp1 = icmp ugt i32 %a, %b 533 br i1 %cmp1, label %taken, label %untaken 534 535 taken: 536 %cmp2 = icmp ugt i32 %a, %b 537 br i1 %cmp2, label %ugt_ugt_istrue, label %ugt_ugt_isfalse 538 539 ugt_ugt_istrue: 540 call void @is(i1 true) 541 ret void 542 543 ugt_ugt_isfalse: 544 call void @is(i1 false) 545 ret void 546 547 untaken: 548 ret void 549 } 550 551 ; A >u B implies A >=u B is true. 552 ; CHECK-LABEL: @test_ugt_uge 553 ; CHECK: call void @is(i1 true) 554 ; CHECK-NOT: call void @is(i1 false) 555 define void @test_ugt_uge(i32 %a, i32 %b) { 556 %cmp1 = icmp ugt i32 %a, %b 557 br i1 %cmp1, label %taken, label %untaken 558 559 taken: 560 %cmp2 = icmp uge i32 %a, %b 561 br i1 %cmp2, label %ugt_uge_istrue, label %ugt_uge_isfalse 562 563 ugt_uge_istrue: 564 call void @is(i1 true) 565 ret void 566 567 ugt_uge_isfalse: 568 call void @is(i1 false) 569 ret void 570 571 untaken: 572 ret void 573 } 574 575 ; A >u B implies A <u B is false. 576 ; CHECK-LABEL: @test_ugt_ult 577 ; CHECK-NOT: call void @is(i1 true) 578 ; CHECK: call void @is(i1 false) 579 define void @test_ugt_ult(i32 %a, i32 %b) { 580 %cmp1 = icmp ugt i32 %a, %b 581 br i1 %cmp1, label %taken, label %untaken 582 583 taken: 584 %cmp2 = icmp ult i32 %a, %b 585 br i1 %cmp2, label %ugt_ult_istrue, label %ugt_ult_isfalse 586 587 ugt_ult_istrue: 588 call void @is(i1 true) 589 ret void 590 591 ugt_ult_isfalse: 592 call void @is(i1 false) 593 ret void 594 595 untaken: 596 ret void 597 } 598 599 ; A >u B implies A <=u B is false. 600 ; CHECK-LABEL: @test_ugt_ule 601 ; CHECK-NOT: call void @is(i1 true) 602 ; CHECK: call void @is(i1 false) 603 define void @test_ugt_ule(i32 %a, i32 %b) { 604 %cmp1 = icmp ugt i32 %a, %b 605 br i1 %cmp1, label %taken, label %untaken 606 607 taken: 608 %cmp2 = icmp ule i32 %a, %b 609 br i1 %cmp2, label %ugt_ule_istrue, label %ugt_ule_isfalse 610 611 ugt_ule_istrue: 612 call void @is(i1 true) 613 ret void 614 615 ugt_ule_isfalse: 616 call void @is(i1 false) 617 ret void 618 619 untaken: 620 ret void 621 } 622 623 ; A >=u B implies A >=u B is true. 624 ; CHECK-LABEL: @test_uge_uge 625 ; CHECK: call void @is(i1 true) 626 ; CHECK-NOT: call void @is(i1 false) 627 define void @test_uge_uge(i32 %a, i32 %b) { 628 %cmp1 = icmp uge i32 %a, %b 629 br i1 %cmp1, label %taken, label %untaken 630 631 taken: 632 %cmp2 = icmp uge i32 %a, %b 633 br i1 %cmp2, label %uge_uge_istrue, label %uge_uge_isfalse 634 635 uge_uge_istrue: 636 call void @is(i1 true) 637 ret void 638 639 uge_uge_isfalse: 640 call void @is(i1 false) 641 ret void 642 643 untaken: 644 ret void 645 } 646 647 ; A >=u B implies A <u B is false. 648 ; CHECK-LABEL: @test_uge_ult 649 ; CHECK-NOT: call void @is(i1 true) 650 ; CHECK: call void @is(i1 false) 651 define void @test_uge_ult(i32 %a, i32 %b) { 652 %cmp1 = icmp uge i32 %a, %b 653 br i1 %cmp1, label %taken, label %untaken 654 655 taken: 656 %cmp2 = icmp ult i32 %a, %b 657 br i1 %cmp2, label %uge_ult_istrue, label %uge_ult_isfalse 658 659 uge_ult_istrue: 660 call void @is(i1 true) 661 ret void 662 663 uge_ult_isfalse: 664 call void @is(i1 false) 665 ret void 666 667 untaken: 668 ret void 669 } 670 671 ; A >=u B implies A <=u B is unknown to be true or false. 672 ; CHECK-LABEL: @test_uge_ule 673 ; CHECK: call void @is(i1 true) 674 ; CHECK: call void @is(i1 false) 675 define void @test_uge_ule(i32 %a, i32 %b) { 676 %cmp1 = icmp uge i32 %a, %b 677 br i1 %cmp1, label %taken, label %untaken 678 679 taken: 680 %cmp2 = icmp ule i32 %a, %b 681 br i1 %cmp2, label %uge_ule_istrue, label %uge_ule_isfalse 682 683 uge_ule_istrue: 684 call void @is(i1 true) 685 ret void 686 687 uge_ule_isfalse: 688 call void @is(i1 false) 689 ret void 690 691 untaken: 692 ret void 693 } 694 695 ; A <u B implies A <u B is true. 696 ; CHECK-LABEL: @test_ult_ult 697 ; CHECK: call void @is(i1 true) 698 ; CHECK-NOT: call void @is(i1 false) 699 define void @test_ult_ult(i32 %a, i32 %b) { 700 %cmp1 = icmp ult i32 %a, %b 701 br i1 %cmp1, label %taken, label %untaken 702 703 taken: 704 %cmp2 = icmp ult i32 %a, %b 705 br i1 %cmp2, label %ult_ult_istrue, label %ult_ult_isfalse 706 707 ult_ult_istrue: 708 call void @is(i1 true) 709 ret void 710 711 ult_ult_isfalse: 712 call void @is(i1 false) 713 ret void 714 715 untaken: 716 ret void 717 } 718 719 ; A <u B implies A <=u B is true. 720 ; CHECK-LABEL: @test_ult_ule 721 ; CHECK: call void @is(i1 true) 722 ; CHECK-NOT: call void @is(i1 false) 723 define void @test_ult_ule(i32 %a, i32 %b) { 724 %cmp1 = icmp ult i32 %a, %b 725 br i1 %cmp1, label %taken, label %untaken 726 727 taken: 728 %cmp2 = icmp ule i32 %a, %b 729 br i1 %cmp2, label %ult_ule_istrue, label %ult_ule_isfalse 730 731 ult_ule_istrue: 732 call void @is(i1 true) 733 ret void 734 735 ult_ule_isfalse: 736 call void @is(i1 false) 737 ret void 738 739 untaken: 740 ret void 741 } 742 743 ; A <=u B implies A <=u B is true. 744 ; CHECK-LABEL: @test_ule_ule 745 ; CHECK: call void @is(i1 true) 746 ; CHECK-NOT: call void @is(i1 false) 747 define void @test_ule_ule(i32 %a, i32 %b) { 748 %cmp1 = icmp ule i32 %a, %b 749 br i1 %cmp1, label %taken, label %untaken 750 751 taken: 752 %cmp2 = icmp ule i32 %a, %b 753 br i1 %cmp2, label %ule_ule_istrue, label %ule_ule_isfalse 754 755 ule_ule_istrue: 756 call void @is(i1 true) 757 ret void 758 759 ule_ule_isfalse: 760 call void @is(i1 false) 761 ret void 762 763 untaken: 764 ret void 765 } 766 767 ; A >s B implies A >s B is true. 768 ; CHECK-LABEL: @test_sgt_sgt 769 ; CHECK: call void @is(i1 true) 770 ; CHECK-NOT: call void @is(i1 false) 771 define void @test_sgt_sgt(i32 %a, i32 %b) { 772 %cmp1 = icmp sgt i32 %a, %b 773 br i1 %cmp1, label %taken, label %untaken 774 775 taken: 776 %cmp2 = icmp sgt i32 %a, %b 777 br i1 %cmp2, label %sgt_sgt_istrue, label %sgt_sgt_isfalse 778 779 sgt_sgt_istrue: 780 call void @is(i1 true) 781 ret void 782 783 sgt_sgt_isfalse: 784 call void @is(i1 false) 785 ret void 786 787 untaken: 788 ret void 789 } 790 791 ; A >s B implies A >=s B is true. 792 ; CHECK-LABEL: @test_sgt_sge 793 ; CHECK: call void @is(i1 true) 794 ; CHECK-NOT: call void @is(i1 false) 795 define void @test_sgt_sge(i32 %a, i32 %b) { 796 %cmp1 = icmp sgt i32 %a, %b 797 br i1 %cmp1, label %taken, label %untaken 798 799 taken: 800 %cmp2 = icmp sge i32 %a, %b 801 br i1 %cmp2, label %sgt_sge_istrue, label %sgt_sge_isfalse 802 803 sgt_sge_istrue: 804 call void @is(i1 true) 805 ret void 806 807 sgt_sge_isfalse: 808 call void @is(i1 false) 809 ret void 810 811 untaken: 812 ret void 813 } 814 815 ; A >s B implies A <s B is false. 816 ; CHECK-LABEL: @test_sgt_slt 817 ; CHECK-NOT: call void @is(i1 true) 818 ; CHECK: call void @is(i1 false) 819 define void @test_sgt_slt(i32 %a, i32 %b) { 820 %cmp1 = icmp sgt i32 %a, %b 821 br i1 %cmp1, label %taken, label %untaken 822 823 taken: 824 %cmp2 = icmp slt i32 %a, %b 825 br i1 %cmp2, label %sgt_slt_istrue, label %sgt_slt_isfalse 826 827 sgt_slt_istrue: 828 call void @is(i1 true) 829 ret void 830 831 sgt_slt_isfalse: 832 call void @is(i1 false) 833 ret void 834 835 untaken: 836 ret void 837 } 838 839 ; A >s B implies A <=s B is false. 840 ; CHECK-LABEL: @test_sgt_sle 841 ; CHECK-NOT: call void @is(i1 true) 842 ; CHECK: call void @is(i1 false) 843 define void @test_sgt_sle(i32 %a, i32 %b) { 844 %cmp1 = icmp sgt i32 %a, %b 845 br i1 %cmp1, label %taken, label %untaken 846 847 taken: 848 %cmp2 = icmp sle i32 %a, %b 849 br i1 %cmp2, label %sgt_sle_istrue, label %sgt_sle_isfalse 850 851 sgt_sle_istrue: 852 call void @is(i1 true) 853 ret void 854 855 sgt_sle_isfalse: 856 call void @is(i1 false) 857 ret void 858 859 untaken: 860 ret void 861 } 862 863 ; A >=s B implies A >=s B is true. 864 ; CHECK-LABEL: @test_sge_sge 865 ; CHECK: call void @is(i1 true) 866 ; CHECK-NOT: call void @is(i1 false) 867 define void @test_sge_sge(i32 %a, i32 %b) { 868 %cmp1 = icmp sge i32 %a, %b 869 br i1 %cmp1, label %taken, label %untaken 870 871 taken: 872 %cmp2 = icmp sge i32 %a, %b 873 br i1 %cmp2, label %sge_sge_istrue, label %sge_sge_isfalse 874 875 sge_sge_istrue: 876 call void @is(i1 true) 877 ret void 878 879 sge_sge_isfalse: 880 call void @is(i1 false) 881 ret void 882 883 untaken: 884 ret void 885 } 886 887 ; A >=s B implies A <s B is false. 888 ; CHECK-LABEL: @test_sge_slt 889 ; CHECK-NOT: call void @is(i1 true) 890 ; CHECK: call void @is(i1 false) 891 define void @test_sge_slt(i32 %a, i32 %b) { 892 %cmp1 = icmp sge i32 %a, %b 893 br i1 %cmp1, label %taken, label %untaken 894 895 taken: 896 %cmp2 = icmp slt i32 %a, %b 897 br i1 %cmp2, label %sge_slt_istrue, label %sge_slt_isfalse 898 899 sge_slt_istrue: 900 call void @is(i1 true) 901 ret void 902 903 sge_slt_isfalse: 904 call void @is(i1 false) 905 ret void 906 907 untaken: 908 ret void 909 } 910 911 ; A >=s B implies A <=s B is unknown to be true or false. 912 ; CHECK-LABEL: @test_sge_sle 913 ; CHECK: call void @is(i1 true) 914 ; CHECK: call void @is(i1 false) 915 define void @test_sge_sle(i32 %a, i32 %b) { 916 %cmp1 = icmp sge i32 %a, %b 917 br i1 %cmp1, label %taken, label %untaken 918 919 taken: 920 %cmp2 = icmp sle i32 %a, %b 921 br i1 %cmp2, label %sge_sle_istrue, label %sge_sle_isfalse 922 923 sge_sle_istrue: 924 call void @is(i1 true) 925 ret void 926 927 sge_sle_isfalse: 928 call void @is(i1 false) 929 ret void 930 931 untaken: 932 ret void 933 } 934 935 ; A <s B implies A <s B is true. 936 ; CHECK-LABEL: @test_slt_slt 937 ; CHECK: call void @is(i1 true) 938 ; CHECK-NOT: call void @is(i1 false) 939 define void @test_slt_slt(i32 %a, i32 %b) { 940 %cmp1 = icmp slt i32 %a, %b 941 br i1 %cmp1, label %taken, label %untaken 942 943 taken: 944 %cmp2 = icmp slt i32 %a, %b 945 br i1 %cmp2, label %slt_slt_istrue, label %slt_slt_isfalse 946 947 slt_slt_istrue: 948 call void @is(i1 true) 949 ret void 950 951 slt_slt_isfalse: 952 call void @is(i1 false) 953 ret void 954 955 untaken: 956 ret void 957 } 958 959 ; A <s B implies A <=s B is true. 960 ; CHECK-LABEL: @test_slt_sle 961 ; CHECK: call void @is(i1 true) 962 ; CHECK-NOT: call void @is(i1 false) 963 define void @test_slt_sle(i32 %a, i32 %b) { 964 %cmp1 = icmp slt i32 %a, %b 965 br i1 %cmp1, label %taken, label %untaken 966 967 taken: 968 %cmp2 = icmp sle i32 %a, %b 969 br i1 %cmp2, label %slt_sle_istrue, label %slt_sle_isfalse 970 971 slt_sle_istrue: 972 call void @is(i1 true) 973 ret void 974 975 slt_sle_isfalse: 976 call void @is(i1 false) 977 ret void 978 979 untaken: 980 ret void 981 } 982 983 ; A <=s B implies A <=s B is true. 984 ; CHECK-LABEL: @test_sle_sle 985 ; CHECK: call void @is(i1 true) 986 ; CHECK-NOT: call void @is(i1 false) 987 define void @test_sle_sle(i32 %a, i32 %b) { 988 %cmp1 = icmp sle i32 %a, %b 989 br i1 %cmp1, label %taken, label %untaken 990 991 taken: 992 %cmp2 = icmp sle i32 %a, %b 993 br i1 %cmp2, label %sle_sle_istrue, label %sle_sle_isfalse 994 995 sle_sle_istrue: 996 call void @is(i1 true) 997 ret void 998 999 sle_sle_isfalse: 1000 call void @is(i1 false) 1001 ret void 1002 1003 untaken: 1004 ret void 1005 } 1006 1007 ; A >=u 5 implies A <u 5 is false. 1008 ; CHECK-LABEL: @test_uge_ult_const 1009 ; CHECK-NOT: call void @is(i1 true) 1010 ; CHECK: call void @is(i1 false) 1011 define void @test_uge_ult_const(i32 %a, i32 %b) { 1012 %cmp1 = icmp uge i32 %a, 5 1013 br i1 %cmp1, label %taken, label %untaken 1014 1015 taken: 1016 %cmp2 = icmp ult i32 %a, 5 1017 br i1 %cmp2, label %istrue, label %isfalse 1018 1019 istrue: 1020 call void @is(i1 true) 1021 ret void 1022 1023 isfalse: 1024 call void @is(i1 false) 1025 ret void 1026 1027 untaken: 1028 ret void 1029 } 1030