1; RUN: opt %s -S -simplifycfg | FileCheck %s 2 3declare void @dead() 4declare void @alive() 5declare 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 20define void @test_swapped_ops(i32 %a, i32 %b) { 21entry: 22 %cmp = icmp ugt i32 %a, %b 23 br i1 %cmp, label %if.then, label %if.end3 24 25if.then: 26 %cmp1 = icmp ugt i32 %b, %a 27 br i1 %cmp1, label %if.then2, label %if.end 28 29if.then2: 30 call void @dead() 31 br label %if.end 32 33if.end: 34 call void @alive() 35 br label %if.end3 36 37if.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 53define void @test_swapped_pred(i32 %a, i32 %b) { 54entry: 55 %cmp = icmp ugt i32 %a, %b 56 br i1 %cmp, label %if.then, label %if.end3 57 58if.then: 59 call void @alive() 60 %cmp1 = icmp ult i32 %b, %a 61 br i1 %cmp1, label %if.then2, label %if.end3 62 63if.then2: 64 call void @alive() 65 br label %if.end3 66 67if.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) 75define void @test_eq_eq(i32 %a, i32 %b) { 76 %cmp1 = icmp eq i32 %a, %b 77 br i1 %cmp1, label %taken, label %untaken 78 79taken: 80 %cmp2 = icmp eq i32 %a, %b 81 br i1 %cmp2, label %eq_eq_istrue, label %eq_eq_isfalse 82 83eq_eq_istrue: 84 call void @is(i1 true) 85 ret void 86 87eq_eq_isfalse: 88 call void @is(i1 false) 89 ret void 90 91untaken: 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) 99define void @test_eq_ne(i32 %a, i32 %b) { 100 %cmp1 = icmp eq i32 %a, %b 101 br i1 %cmp1, label %taken, label %untaken 102 103taken: 104 %cmp2 = icmp ne i32 %a, %b 105 br i1 %cmp2, label %eq_ne_istrue, label %eq_ne_isfalse 106 107eq_ne_istrue: 108 call void @is(i1 true) 109 ret void 110 111eq_ne_isfalse: 112 call void @is(i1 false) 113 ret void 114 115untaken: 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) 123define void @test_eq_ugt(i32 %a, i32 %b) { 124 %cmp1 = icmp eq i32 %a, %b 125 br i1 %cmp1, label %taken, label %untaken 126 127taken: 128 %cmp2 = icmp ugt i32 %a, %b 129 br i1 %cmp2, label %eq_ugt_istrue, label %eq_ugt_isfalse 130 131eq_ugt_istrue: 132 call void @is(i1 true) 133 ret void 134 135eq_ugt_isfalse: 136 call void @is(i1 false) 137 ret void 138 139untaken: 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) 147define void @test_eq_uge(i32 %a, i32 %b) { 148 %cmp1 = icmp eq i32 %a, %b 149 br i1 %cmp1, label %taken, label %untaken 150 151taken: 152 %cmp2 = icmp uge i32 %a, %b 153 br i1 %cmp2, label %eq_uge_istrue, label %eq_uge_isfalse 154 155eq_uge_istrue: 156 call void @is(i1 true) 157 ret void 158 159eq_uge_isfalse: 160 call void @is(i1 false) 161 ret void 162 163untaken: 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) 171define void @test_eq_ult(i32 %a, i32 %b) { 172 %cmp1 = icmp eq i32 %a, %b 173 br i1 %cmp1, label %taken, label %untaken 174 175taken: 176 %cmp2 = icmp ult i32 %a, %b 177 br i1 %cmp2, label %eq_ult_istrue, label %eq_ult_isfalse 178 179eq_ult_istrue: 180 call void @is(i1 true) 181 ret void 182 183eq_ult_isfalse: 184 call void @is(i1 false) 185 ret void 186 187untaken: 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) 195define void @test_eq_ule(i32 %a, i32 %b) { 196 %cmp1 = icmp eq i32 %a, %b 197 br i1 %cmp1, label %taken, label %untaken 198 199taken: 200 %cmp2 = icmp ule i32 %a, %b 201 br i1 %cmp2, label %eq_ule_istrue, label %eq_ule_isfalse 202 203eq_ule_istrue: 204 call void @is(i1 true) 205 ret void 206 207eq_ule_isfalse: 208 call void @is(i1 false) 209 ret void 210 211untaken: 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) 219define void @test_eq_sgt(i32 %a, i32 %b) { 220 %cmp1 = icmp eq i32 %a, %b 221 br i1 %cmp1, label %taken, label %untaken 222 223taken: 224 %cmp2 = icmp sgt i32 %a, %b 225 br i1 %cmp2, label %eq_sgt_istrue, label %eq_sgt_isfalse 226 227eq_sgt_istrue: 228 call void @is(i1 true) 229 ret void 230 231eq_sgt_isfalse: 232 call void @is(i1 false) 233 ret void 234 235untaken: 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) 243define void @test_eq_sge(i32 %a, i32 %b) { 244 %cmp1 = icmp eq i32 %a, %b 245 br i1 %cmp1, label %taken, label %untaken 246 247taken: 248 %cmp2 = icmp sge i32 %a, %b 249 br i1 %cmp2, label %eq_sge_istrue, label %eq_sge_isfalse 250 251eq_sge_istrue: 252 call void @is(i1 true) 253 ret void 254 255eq_sge_isfalse: 256 call void @is(i1 false) 257 ret void 258 259untaken: 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) 267define void @test_eq_slt(i32 %a, i32 %b) { 268 %cmp1 = icmp eq i32 %a, %b 269 br i1 %cmp1, label %taken, label %untaken 270 271taken: 272 %cmp2 = icmp slt i32 %a, %b 273 br i1 %cmp2, label %eq_slt_istrue, label %eq_slt_isfalse 274 275eq_slt_istrue: 276 call void @is(i1 true) 277 ret void 278 279eq_slt_isfalse: 280 call void @is(i1 false) 281 ret void 282 283untaken: 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) 291define void @test_eq_sle(i32 %a, i32 %b) { 292 %cmp1 = icmp eq i32 %a, %b 293 br i1 %cmp1, label %taken, label %untaken 294 295taken: 296 %cmp2 = icmp sle i32 %a, %b 297 br i1 %cmp2, label %eq_sle_istrue, label %eq_sle_isfalse 298 299eq_sle_istrue: 300 call void @is(i1 true) 301 ret void 302 303eq_sle_isfalse: 304 call void @is(i1 false) 305 ret void 306 307untaken: 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) 315define void @test_ne_ne(i32 %a, i32 %b) { 316 %cmp1 = icmp ne i32 %a, %b 317 br i1 %cmp1, label %taken, label %untaken 318 319taken: 320 %cmp2 = icmp ne i32 %a, %b 321 br i1 %cmp2, label %ne_ne_istrue, label %ne_ne_isfalse 322 323ne_ne_istrue: 324 call void @is(i1 true) 325 ret void 326 327ne_ne_isfalse: 328 call void @is(i1 false) 329 ret void 330 331untaken: 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) 339define void @test_ne_ugt(i32 %a, i32 %b) { 340 %cmp1 = icmp ne i32 %a, %b 341 br i1 %cmp1, label %taken, label %untaken 342 343taken: 344 %cmp2 = icmp ugt i32 %a, %b 345 br i1 %cmp2, label %ne_ugt_istrue, label %ne_ugt_isfalse 346 347ne_ugt_istrue: 348 call void @is(i1 true) 349 ret void 350 351ne_ugt_isfalse: 352 call void @is(i1 false) 353 ret void 354 355untaken: 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) 363define void @test_ne_uge(i32 %a, i32 %b) { 364 %cmp1 = icmp ne i32 %a, %b 365 br i1 %cmp1, label %taken, label %untaken 366 367taken: 368 %cmp2 = icmp uge i32 %a, %b 369 br i1 %cmp2, label %ne_uge_istrue, label %ne_uge_isfalse 370 371ne_uge_istrue: 372 call void @is(i1 true) 373 ret void 374 375ne_uge_isfalse: 376 call void @is(i1 false) 377 ret void 378 379untaken: 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) 387define void @test_ne_ult(i32 %a, i32 %b) { 388 %cmp1 = icmp ne i32 %a, %b 389 br i1 %cmp1, label %taken, label %untaken 390 391taken: 392 %cmp2 = icmp ult i32 %a, %b 393 br i1 %cmp2, label %ne_ult_istrue, label %ne_ult_isfalse 394 395ne_ult_istrue: 396 call void @is(i1 true) 397 ret void 398 399ne_ult_isfalse: 400 call void @is(i1 false) 401 ret void 402 403untaken: 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) 411define void @test_ne_ule(i32 %a, i32 %b) { 412 %cmp1 = icmp ne i32 %a, %b 413 br i1 %cmp1, label %taken, label %untaken 414 415taken: 416 %cmp2 = icmp ule i32 %a, %b 417 br i1 %cmp2, label %ne_ule_istrue, label %ne_ule_isfalse 418 419ne_ule_istrue: 420 call void @is(i1 true) 421 ret void 422 423ne_ule_isfalse: 424 call void @is(i1 false) 425 ret void 426 427untaken: 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) 435define void @test_ne_sgt(i32 %a, i32 %b) { 436 %cmp1 = icmp ne i32 %a, %b 437 br i1 %cmp1, label %taken, label %untaken 438 439taken: 440 %cmp2 = icmp sgt i32 %a, %b 441 br i1 %cmp2, label %ne_sgt_istrue, label %ne_sgt_isfalse 442 443ne_sgt_istrue: 444 call void @is(i1 true) 445 ret void 446 447ne_sgt_isfalse: 448 call void @is(i1 false) 449 ret void 450 451untaken: 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) 459define void @test_ne_sge(i32 %a, i32 %b) { 460 %cmp1 = icmp ne i32 %a, %b 461 br i1 %cmp1, label %taken, label %untaken 462 463taken: 464 %cmp2 = icmp sge i32 %a, %b 465 br i1 %cmp2, label %ne_sge_istrue, label %ne_sge_isfalse 466 467ne_sge_istrue: 468 call void @is(i1 true) 469 ret void 470 471ne_sge_isfalse: 472 call void @is(i1 false) 473 ret void 474 475untaken: 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) 483define void @test_ne_slt(i32 %a, i32 %b) { 484 %cmp1 = icmp ne i32 %a, %b 485 br i1 %cmp1, label %taken, label %untaken 486 487taken: 488 %cmp2 = icmp slt i32 %a, %b 489 br i1 %cmp2, label %ne_slt_istrue, label %ne_slt_isfalse 490 491ne_slt_istrue: 492 call void @is(i1 true) 493 ret void 494 495ne_slt_isfalse: 496 call void @is(i1 false) 497 ret void 498 499untaken: 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) 507define void @test_ne_sle(i32 %a, i32 %b) { 508 %cmp1 = icmp ne i32 %a, %b 509 br i1 %cmp1, label %taken, label %untaken 510 511taken: 512 %cmp2 = icmp sle i32 %a, %b 513 br i1 %cmp2, label %ne_sle_istrue, label %ne_sle_isfalse 514 515ne_sle_istrue: 516 call void @is(i1 true) 517 ret void 518 519ne_sle_isfalse: 520 call void @is(i1 false) 521 ret void 522 523untaken: 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) 531define void @test_ugt_ugt(i32 %a, i32 %b) { 532 %cmp1 = icmp ugt i32 %a, %b 533 br i1 %cmp1, label %taken, label %untaken 534 535taken: 536 %cmp2 = icmp ugt i32 %a, %b 537 br i1 %cmp2, label %ugt_ugt_istrue, label %ugt_ugt_isfalse 538 539ugt_ugt_istrue: 540 call void @is(i1 true) 541 ret void 542 543ugt_ugt_isfalse: 544 call void @is(i1 false) 545 ret void 546 547untaken: 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) 555define void @test_ugt_uge(i32 %a, i32 %b) { 556 %cmp1 = icmp ugt i32 %a, %b 557 br i1 %cmp1, label %taken, label %untaken 558 559taken: 560 %cmp2 = icmp uge i32 %a, %b 561 br i1 %cmp2, label %ugt_uge_istrue, label %ugt_uge_isfalse 562 563ugt_uge_istrue: 564 call void @is(i1 true) 565 ret void 566 567ugt_uge_isfalse: 568 call void @is(i1 false) 569 ret void 570 571untaken: 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) 579define void @test_ugt_ult(i32 %a, i32 %b) { 580 %cmp1 = icmp ugt i32 %a, %b 581 br i1 %cmp1, label %taken, label %untaken 582 583taken: 584 %cmp2 = icmp ult i32 %a, %b 585 br i1 %cmp2, label %ugt_ult_istrue, label %ugt_ult_isfalse 586 587ugt_ult_istrue: 588 call void @is(i1 true) 589 ret void 590 591ugt_ult_isfalse: 592 call void @is(i1 false) 593 ret void 594 595untaken: 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) 603define void @test_ugt_ule(i32 %a, i32 %b) { 604 %cmp1 = icmp ugt i32 %a, %b 605 br i1 %cmp1, label %taken, label %untaken 606 607taken: 608 %cmp2 = icmp ule i32 %a, %b 609 br i1 %cmp2, label %ugt_ule_istrue, label %ugt_ule_isfalse 610 611ugt_ule_istrue: 612 call void @is(i1 true) 613 ret void 614 615ugt_ule_isfalse: 616 call void @is(i1 false) 617 ret void 618 619untaken: 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) 627define void @test_uge_uge(i32 %a, i32 %b) { 628 %cmp1 = icmp uge i32 %a, %b 629 br i1 %cmp1, label %taken, label %untaken 630 631taken: 632 %cmp2 = icmp uge i32 %a, %b 633 br i1 %cmp2, label %uge_uge_istrue, label %uge_uge_isfalse 634 635uge_uge_istrue: 636 call void @is(i1 true) 637 ret void 638 639uge_uge_isfalse: 640 call void @is(i1 false) 641 ret void 642 643untaken: 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) 651define void @test_uge_ult(i32 %a, i32 %b) { 652 %cmp1 = icmp uge i32 %a, %b 653 br i1 %cmp1, label %taken, label %untaken 654 655taken: 656 %cmp2 = icmp ult i32 %a, %b 657 br i1 %cmp2, label %uge_ult_istrue, label %uge_ult_isfalse 658 659uge_ult_istrue: 660 call void @is(i1 true) 661 ret void 662 663uge_ult_isfalse: 664 call void @is(i1 false) 665 ret void 666 667untaken: 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) 675define void @test_uge_ule(i32 %a, i32 %b) { 676 %cmp1 = icmp uge i32 %a, %b 677 br i1 %cmp1, label %taken, label %untaken 678 679taken: 680 %cmp2 = icmp ule i32 %a, %b 681 br i1 %cmp2, label %uge_ule_istrue, label %uge_ule_isfalse 682 683uge_ule_istrue: 684 call void @is(i1 true) 685 ret void 686 687uge_ule_isfalse: 688 call void @is(i1 false) 689 ret void 690 691untaken: 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) 699define void @test_ult_ult(i32 %a, i32 %b) { 700 %cmp1 = icmp ult i32 %a, %b 701 br i1 %cmp1, label %taken, label %untaken 702 703taken: 704 %cmp2 = icmp ult i32 %a, %b 705 br i1 %cmp2, label %ult_ult_istrue, label %ult_ult_isfalse 706 707ult_ult_istrue: 708 call void @is(i1 true) 709 ret void 710 711ult_ult_isfalse: 712 call void @is(i1 false) 713 ret void 714 715untaken: 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) 723define void @test_ult_ule(i32 %a, i32 %b) { 724 %cmp1 = icmp ult i32 %a, %b 725 br i1 %cmp1, label %taken, label %untaken 726 727taken: 728 %cmp2 = icmp ule i32 %a, %b 729 br i1 %cmp2, label %ult_ule_istrue, label %ult_ule_isfalse 730 731ult_ule_istrue: 732 call void @is(i1 true) 733 ret void 734 735ult_ule_isfalse: 736 call void @is(i1 false) 737 ret void 738 739untaken: 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) 747define void @test_ule_ule(i32 %a, i32 %b) { 748 %cmp1 = icmp ule i32 %a, %b 749 br i1 %cmp1, label %taken, label %untaken 750 751taken: 752 %cmp2 = icmp ule i32 %a, %b 753 br i1 %cmp2, label %ule_ule_istrue, label %ule_ule_isfalse 754 755ule_ule_istrue: 756 call void @is(i1 true) 757 ret void 758 759ule_ule_isfalse: 760 call void @is(i1 false) 761 ret void 762 763untaken: 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) 771define void @test_sgt_sgt(i32 %a, i32 %b) { 772 %cmp1 = icmp sgt i32 %a, %b 773 br i1 %cmp1, label %taken, label %untaken 774 775taken: 776 %cmp2 = icmp sgt i32 %a, %b 777 br i1 %cmp2, label %sgt_sgt_istrue, label %sgt_sgt_isfalse 778 779sgt_sgt_istrue: 780 call void @is(i1 true) 781 ret void 782 783sgt_sgt_isfalse: 784 call void @is(i1 false) 785 ret void 786 787untaken: 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) 795define void @test_sgt_sge(i32 %a, i32 %b) { 796 %cmp1 = icmp sgt i32 %a, %b 797 br i1 %cmp1, label %taken, label %untaken 798 799taken: 800 %cmp2 = icmp sge i32 %a, %b 801 br i1 %cmp2, label %sgt_sge_istrue, label %sgt_sge_isfalse 802 803sgt_sge_istrue: 804 call void @is(i1 true) 805 ret void 806 807sgt_sge_isfalse: 808 call void @is(i1 false) 809 ret void 810 811untaken: 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) 819define void @test_sgt_slt(i32 %a, i32 %b) { 820 %cmp1 = icmp sgt i32 %a, %b 821 br i1 %cmp1, label %taken, label %untaken 822 823taken: 824 %cmp2 = icmp slt i32 %a, %b 825 br i1 %cmp2, label %sgt_slt_istrue, label %sgt_slt_isfalse 826 827sgt_slt_istrue: 828 call void @is(i1 true) 829 ret void 830 831sgt_slt_isfalse: 832 call void @is(i1 false) 833 ret void 834 835untaken: 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) 843define void @test_sgt_sle(i32 %a, i32 %b) { 844 %cmp1 = icmp sgt i32 %a, %b 845 br i1 %cmp1, label %taken, label %untaken 846 847taken: 848 %cmp2 = icmp sle i32 %a, %b 849 br i1 %cmp2, label %sgt_sle_istrue, label %sgt_sle_isfalse 850 851sgt_sle_istrue: 852 call void @is(i1 true) 853 ret void 854 855sgt_sle_isfalse: 856 call void @is(i1 false) 857 ret void 858 859untaken: 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) 867define void @test_sge_sge(i32 %a, i32 %b) { 868 %cmp1 = icmp sge i32 %a, %b 869 br i1 %cmp1, label %taken, label %untaken 870 871taken: 872 %cmp2 = icmp sge i32 %a, %b 873 br i1 %cmp2, label %sge_sge_istrue, label %sge_sge_isfalse 874 875sge_sge_istrue: 876 call void @is(i1 true) 877 ret void 878 879sge_sge_isfalse: 880 call void @is(i1 false) 881 ret void 882 883untaken: 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) 891define void @test_sge_slt(i32 %a, i32 %b) { 892 %cmp1 = icmp sge i32 %a, %b 893 br i1 %cmp1, label %taken, label %untaken 894 895taken: 896 %cmp2 = icmp slt i32 %a, %b 897 br i1 %cmp2, label %sge_slt_istrue, label %sge_slt_isfalse 898 899sge_slt_istrue: 900 call void @is(i1 true) 901 ret void 902 903sge_slt_isfalse: 904 call void @is(i1 false) 905 ret void 906 907untaken: 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) 915define void @test_sge_sle(i32 %a, i32 %b) { 916 %cmp1 = icmp sge i32 %a, %b 917 br i1 %cmp1, label %taken, label %untaken 918 919taken: 920 %cmp2 = icmp sle i32 %a, %b 921 br i1 %cmp2, label %sge_sle_istrue, label %sge_sle_isfalse 922 923sge_sle_istrue: 924 call void @is(i1 true) 925 ret void 926 927sge_sle_isfalse: 928 call void @is(i1 false) 929 ret void 930 931untaken: 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) 939define void @test_slt_slt(i32 %a, i32 %b) { 940 %cmp1 = icmp slt i32 %a, %b 941 br i1 %cmp1, label %taken, label %untaken 942 943taken: 944 %cmp2 = icmp slt i32 %a, %b 945 br i1 %cmp2, label %slt_slt_istrue, label %slt_slt_isfalse 946 947slt_slt_istrue: 948 call void @is(i1 true) 949 ret void 950 951slt_slt_isfalse: 952 call void @is(i1 false) 953 ret void 954 955untaken: 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) 963define void @test_slt_sle(i32 %a, i32 %b) { 964 %cmp1 = icmp slt i32 %a, %b 965 br i1 %cmp1, label %taken, label %untaken 966 967taken: 968 %cmp2 = icmp sle i32 %a, %b 969 br i1 %cmp2, label %slt_sle_istrue, label %slt_sle_isfalse 970 971slt_sle_istrue: 972 call void @is(i1 true) 973 ret void 974 975slt_sle_isfalse: 976 call void @is(i1 false) 977 ret void 978 979untaken: 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) 987define void @test_sle_sle(i32 %a, i32 %b) { 988 %cmp1 = icmp sle i32 %a, %b 989 br i1 %cmp1, label %taken, label %untaken 990 991taken: 992 %cmp2 = icmp sle i32 %a, %b 993 br i1 %cmp2, label %sle_sle_istrue, label %sle_sle_isfalse 994 995sle_sle_istrue: 996 call void @is(i1 true) 997 ret void 998 999sle_sle_isfalse: 1000 call void @is(i1 false) 1001 ret void 1002 1003untaken: 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) 1011define 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 1015taken: 1016 %cmp2 = icmp ult i32 %a, 5 1017 br i1 %cmp2, label %istrue, label %isfalse 1018 1019istrue: 1020 call void @is(i1 true) 1021 ret void 1022 1023isfalse: 1024 call void @is(i1 false) 1025 ret void 1026 1027untaken: 1028 ret void 1029} 1030