1 ; RUN: opt < %s -instsimplify -S | FileCheck %s 2 target datalayout = "p:32:32" 3 4 define i1 @ptrtoint() { 5 ; CHECK-LABEL: @ptrtoint( 6 %a = alloca i8 7 %tmp = ptrtoint i8* %a to i32 8 %r = icmp eq i32 %tmp, 0 9 ret i1 %r 10 ; CHECK: ret i1 false 11 } 12 13 define i1 @bitcast() { 14 ; CHECK-LABEL: @bitcast( 15 %a = alloca i32 16 %b = alloca i64 17 %x = bitcast i32* %a to i8* 18 %y = bitcast i64* %b to i8* 19 %cmp = icmp eq i8* %x, %y 20 ret i1 %cmp 21 ; CHECK-NEXT: ret i1 false 22 } 23 24 define i1 @gep() { 25 ; CHECK-LABEL: @gep( 26 %a = alloca [3 x i8], align 8 27 %x = getelementptr inbounds [3 x i8], [3 x i8]* %a, i32 0, i32 0 28 %cmp = icmp eq i8* %x, null 29 ret i1 %cmp 30 ; CHECK-NEXT: ret i1 false 31 } 32 33 define i1 @gep2() { 34 ; CHECK-LABEL: @gep2( 35 %a = alloca [3 x i8], align 8 36 %x = getelementptr inbounds [3 x i8], [3 x i8]* %a, i32 0, i32 0 37 %y = getelementptr inbounds [3 x i8], [3 x i8]* %a, i32 0, i32 0 38 %cmp = icmp eq i8* %x, %y 39 ret i1 %cmp 40 ; CHECK-NEXT: ret i1 true 41 } 42 43 ; PR11238 44 %gept = type { i32, i32 } 45 @gepy = global %gept zeroinitializer, align 8 46 @gepz = extern_weak global %gept 47 48 define i1 @gep3() { 49 ; CHECK-LABEL: @gep3( 50 %x = alloca %gept, align 8 51 %a = getelementptr %gept, %gept* %x, i64 0, i32 0 52 %b = getelementptr %gept, %gept* %x, i64 0, i32 1 53 %equal = icmp eq i32* %a, %b 54 ret i1 %equal 55 ; CHECK-NEXT: ret i1 false 56 } 57 58 define i1 @gep4() { 59 ; CHECK-LABEL: @gep4( 60 %x = alloca %gept, align 8 61 %a = getelementptr %gept, %gept* @gepy, i64 0, i32 0 62 %b = getelementptr %gept, %gept* @gepy, i64 0, i32 1 63 %equal = icmp eq i32* %a, %b 64 ret i1 %equal 65 ; CHECK-NEXT: ret i1 false 66 } 67 68 define i1 @gep5() { 69 ; CHECK-LABEL: @gep5( 70 %x = alloca %gept, align 8 71 %a = getelementptr inbounds %gept, %gept* %x, i64 0, i32 1 72 %b = getelementptr %gept, %gept* @gepy, i64 0, i32 0 73 %equal = icmp eq i32* %a, %b 74 ret i1 %equal 75 ; CHECK-NEXT: ret i1 false 76 } 77 78 define i1 @gep6(%gept* %x) { 79 ; Same as @gep3 but potentially null. 80 ; CHECK-LABEL: @gep6( 81 %a = getelementptr %gept, %gept* %x, i64 0, i32 0 82 %b = getelementptr %gept, %gept* %x, i64 0, i32 1 83 %equal = icmp eq i32* %a, %b 84 ret i1 %equal 85 ; CHECK-NEXT: ret i1 false 86 } 87 88 define i1 @gep7(%gept* %x) { 89 ; CHECK-LABEL: @gep7( 90 %a = getelementptr %gept, %gept* %x, i64 0, i32 0 91 %b = getelementptr %gept, %gept* @gepz, i64 0, i32 0 92 %equal = icmp eq i32* %a, %b 93 ret i1 %equal 94 ; CHECK: ret i1 %equal 95 } 96 97 define i1 @gep8(%gept* %x) { 98 ; CHECK-LABEL: @gep8( 99 %a = getelementptr %gept, %gept* %x, i32 1 100 %b = getelementptr %gept, %gept* %x, i32 -1 101 %equal = icmp ugt %gept* %a, %b 102 ret i1 %equal 103 ; CHECK: ret i1 %equal 104 } 105 106 define i1 @gep9(i8* %ptr) { 107 ; CHECK-LABEL: @gep9( 108 ; CHECK-NOT: ret 109 ; CHECK: ret i1 true 110 111 entry: 112 %first1 = getelementptr inbounds i8, i8* %ptr, i32 0 113 %first2 = getelementptr inbounds i8, i8* %first1, i32 1 114 %first3 = getelementptr inbounds i8, i8* %first2, i32 2 115 %first4 = getelementptr inbounds i8, i8* %first3, i32 4 116 %last1 = getelementptr inbounds i8, i8* %first2, i32 48 117 %last2 = getelementptr inbounds i8, i8* %last1, i32 8 118 %last3 = getelementptr inbounds i8, i8* %last2, i32 -4 119 %last4 = getelementptr inbounds i8, i8* %last3, i32 -4 120 %first.int = ptrtoint i8* %first4 to i32 121 %last.int = ptrtoint i8* %last4 to i32 122 %cmp = icmp ne i32 %last.int, %first.int 123 ret i1 %cmp 124 } 125 126 define i1 @gep10(i8* %ptr) { 127 ; CHECK-LABEL: @gep10( 128 ; CHECK-NOT: ret 129 ; CHECK: ret i1 true 130 131 entry: 132 %first1 = getelementptr inbounds i8, i8* %ptr, i32 -2 133 %first2 = getelementptr inbounds i8, i8* %first1, i32 44 134 %last1 = getelementptr inbounds i8, i8* %ptr, i32 48 135 %last2 = getelementptr inbounds i8, i8* %last1, i32 -6 136 %first.int = ptrtoint i8* %first2 to i32 137 %last.int = ptrtoint i8* %last2 to i32 138 %cmp = icmp eq i32 %last.int, %first.int 139 ret i1 %cmp 140 } 141 142 define i1 @gep11(i8* %ptr) { 143 ; CHECK-LABEL: @gep11( 144 ; CHECK-NOT: ret 145 ; CHECK: ret i1 true 146 147 entry: 148 %first1 = getelementptr inbounds i8, i8* %ptr, i32 -2 149 %last1 = getelementptr inbounds i8, i8* %ptr, i32 48 150 %last2 = getelementptr inbounds i8, i8* %last1, i32 -6 151 %cmp = icmp ult i8* %first1, %last2 152 ret i1 %cmp 153 } 154 155 define i1 @gep12(i8* %ptr) { 156 ; CHECK-LABEL: @gep12( 157 ; CHECK-NOT: ret 158 ; CHECK: ret i1 %cmp 159 160 entry: 161 %first1 = getelementptr inbounds i8, i8* %ptr, i32 -2 162 %last1 = getelementptr inbounds i8, i8* %ptr, i32 48 163 %last2 = getelementptr inbounds i8, i8* %last1, i32 -6 164 %cmp = icmp slt i8* %first1, %last2 165 ret i1 %cmp 166 } 167 168 define i1 @gep13(i8* %ptr) { 169 ; CHECK-LABEL: @gep13( 170 ; We can prove this GEP is non-null because it is inbounds. 171 %x = getelementptr inbounds i8, i8* %ptr, i32 1 172 %cmp = icmp eq i8* %x, null 173 ret i1 %cmp 174 ; CHECK-NEXT: ret i1 false 175 } 176 177 define i1 @gep14({ {}, i8 }* %ptr) { 178 ; CHECK-LABEL: @gep14( 179 ; We can't simplify this because the offset of one in the GEP actually doesn't 180 ; move the pointer. 181 %x = getelementptr inbounds { {}, i8 }, { {}, i8 }* %ptr, i32 0, i32 1 182 %cmp = icmp eq i8* %x, null 183 ret i1 %cmp 184 ; CHECK-NOT: ret i1 false 185 } 186 187 define i1 @gep15({ {}, [4 x {i8, i8}]}* %ptr, i32 %y) { 188 ; CHECK-LABEL: @gep15( 189 ; We can prove this GEP is non-null even though there is a user value, as we 190 ; would necessarily violate inbounds on one side or the other. 191 %x = getelementptr inbounds { {}, [4 x {i8, i8}]}, { {}, [4 x {i8, i8}]}* %ptr, i32 0, i32 1, i32 %y, i32 1 192 %cmp = icmp eq i8* %x, null 193 ret i1 %cmp 194 ; CHECK-NEXT: ret i1 false 195 } 196 197 define i1 @gep16(i8* %ptr, i32 %a) { 198 ; CHECK-LABEL: @gep16( 199 ; We can prove this GEP is non-null because it is inbounds and because we know 200 ; %b is non-zero even though we don't know its value. 201 %b = or i32 %a, 1 202 %x = getelementptr inbounds i8, i8* %ptr, i32 %b 203 %cmp = icmp eq i8* %x, null 204 ret i1 %cmp 205 ; CHECK-NEXT: ret i1 false 206 } 207 208 define i1 @zext(i32 %x) { 209 ; CHECK-LABEL: @zext( 210 %e1 = zext i32 %x to i64 211 %e2 = zext i32 %x to i64 212 %r = icmp eq i64 %e1, %e2 213 ret i1 %r 214 ; CHECK: ret i1 true 215 } 216 217 define i1 @zext2(i1 %x) { 218 ; CHECK-LABEL: @zext2( 219 %e = zext i1 %x to i32 220 %c = icmp ne i32 %e, 0 221 ret i1 %c 222 ; CHECK: ret i1 %x 223 } 224 225 define i1 @zext3() { 226 ; CHECK-LABEL: @zext3( 227 %e = zext i1 1 to i32 228 %c = icmp ne i32 %e, 0 229 ret i1 %c 230 ; CHECK: ret i1 true 231 } 232 233 define i1 @sext(i32 %x) { 234 ; CHECK-LABEL: @sext( 235 %e1 = sext i32 %x to i64 236 %e2 = sext i32 %x to i64 237 %r = icmp eq i64 %e1, %e2 238 ret i1 %r 239 ; CHECK: ret i1 true 240 } 241 242 define i1 @sext2(i1 %x) { 243 ; CHECK-LABEL: @sext2( 244 %e = sext i1 %x to i32 245 %c = icmp ne i32 %e, 0 246 ret i1 %c 247 ; CHECK: ret i1 %x 248 } 249 250 define i1 @sext3() { 251 ; CHECK-LABEL: @sext3( 252 %e = sext i1 1 to i32 253 %c = icmp ne i32 %e, 0 254 ret i1 %c 255 ; CHECK: ret i1 true 256 } 257 258 define i1 @add(i32 %x, i32 %y) { 259 ; CHECK-LABEL: @add( 260 %l = lshr i32 %x, 1 261 %q = lshr i32 %y, 1 262 %r = or i32 %q, 1 263 %s = add i32 %l, %r 264 %c = icmp eq i32 %s, 0 265 ret i1 %c 266 ; CHECK: ret i1 false 267 } 268 269 define i1 @add2(i8 %x, i8 %y) { 270 ; CHECK-LABEL: @add2( 271 %l = or i8 %x, 128 272 %r = or i8 %y, 129 273 %s = add i8 %l, %r 274 %c = icmp eq i8 %s, 0 275 ret i1 %c 276 ; CHECK: ret i1 false 277 } 278 279 define i1 @add3(i8 %x, i8 %y) { 280 ; CHECK-LABEL: @add3( 281 %l = zext i8 %x to i32 282 %r = zext i8 %y to i32 283 %s = add i32 %l, %r 284 %c = icmp eq i32 %s, 0 285 ret i1 %c 286 ; CHECK: ret i1 %c 287 } 288 289 define i1 @add4(i32 %x, i32 %y) { 290 ; CHECK-LABEL: @add4( 291 %z = add nsw i32 %y, 1 292 %s1 = add nsw i32 %x, %y 293 %s2 = add nsw i32 %x, %z 294 %c = icmp slt i32 %s1, %s2 295 ret i1 %c 296 ; CHECK: ret i1 true 297 } 298 299 define i1 @add5(i32 %x, i32 %y) { 300 ; CHECK-LABEL: @add5( 301 %z = add nuw i32 %y, 1 302 %s1 = add nuw i32 %x, %z 303 %s2 = add nuw i32 %x, %y 304 %c = icmp ugt i32 %s1, %s2 305 ret i1 %c 306 ; CHECK: ret i1 true 307 } 308 309 define i1 @add6(i64 %A, i64 %B) { 310 ; CHECK-LABEL: @add6( 311 %s1 = add i64 %A, %B 312 %s2 = add i64 %B, %A 313 %cmp = icmp eq i64 %s1, %s2 314 ret i1 %cmp 315 ; CHECK: ret i1 true 316 } 317 318 define i1 @addpowtwo(i32 %x, i32 %y) { 319 ; CHECK-LABEL: @addpowtwo( 320 %l = lshr i32 %x, 1 321 %r = shl i32 1, %y 322 %s = add i32 %l, %r 323 %c = icmp eq i32 %s, 0 324 ret i1 %c 325 ; CHECK: ret i1 false 326 } 327 328 define i1 @or(i32 %x) { 329 ; CHECK-LABEL: @or( 330 %o = or i32 %x, 1 331 %c = icmp eq i32 %o, 0 332 ret i1 %c 333 ; CHECK: ret i1 false 334 } 335 336 ; Do not simplify if we cannot guarantee that the ConstantExpr is a non-zero 337 ; constant. 338 @GV = common global i32* null 339 define i1 @or_constexp(i32 %x) { 340 ; CHECK-LABEL: @or_constexp( 341 entry: 342 %0 = and i32 ptrtoint (i32** @GV to i32), 32 343 %o = or i32 %x, %0 344 %c = icmp eq i32 %o, 0 345 ret i1 %c 346 ; CHECK: or 347 ; CHECK-NEXT: icmp eq 348 ; CHECK-NOT: ret i1 false 349 } 350 351 define i1 @shl1(i32 %x) { 352 ; CHECK-LABEL: @shl1( 353 %s = shl i32 1, %x 354 %c = icmp eq i32 %s, 0 355 ret i1 %c 356 ; CHECK: ret i1 false 357 } 358 359 define i1 @shl2(i32 %X) { 360 ; CHECK: @shl2 361 %sub = shl nsw i32 -1, %X 362 %cmp = icmp eq i32 %sub, 31 363 ret i1 %cmp 364 ; CHECK-NEXT: ret i1 false 365 } 366 367 define i1 @shl3(i32 %X) { 368 ; CHECK: @shl3 369 %sub = shl nuw i32 4, %X 370 %cmp = icmp eq i32 %sub, 31 371 ret i1 %cmp 372 ; CHECK-NEXT: ret i1 false 373 } 374 375 define i1 @shl4(i32 %X) { 376 ; CHECK: @shl4 377 %sub = shl nsw i32 -1, %X 378 %cmp = icmp sle i32 %sub, -1 379 ret i1 %cmp 380 ; CHECK-NEXT: ret i1 true 381 } 382 383 define i1 @shl5(i32 %X) { 384 ; CHECK: @shl5 385 %sub = shl nuw i32 4, %X 386 %cmp = icmp ugt i32 %sub, 3 387 ret i1 %cmp 388 ; CHECK-NEXT: ret i1 true 389 } 390 391 define i1 @lshr1(i32 %x) { 392 ; CHECK-LABEL: @lshr1( 393 %s = lshr i32 -1, %x 394 %c = icmp eq i32 %s, 0 395 ret i1 %c 396 ; CHECK: ret i1 false 397 } 398 399 define i1 @lshr2(i32 %x) { 400 ; CHECK-LABEL: @lshr2( 401 %s = lshr i32 %x, 30 402 %c = icmp ugt i32 %s, 8 403 ret i1 %c 404 ; CHECK: ret i1 false 405 } 406 407 define i1 @lshr3(i32 %x) { 408 ; CHECK-LABEL: @lshr3( 409 %s = lshr i32 %x, %x 410 %c = icmp eq i32 %s, 0 411 ret i1 %c 412 ; CHECK: ret i1 true 413 } 414 415 define i1 @lshr4(i32 %X, i32 %Y) { 416 ; CHECK-LABEL: @lshr4( 417 %A = lshr i32 %X, %Y 418 %C = icmp ule i32 %A, %X 419 ret i1 %C 420 ; CHECK: ret i1 true 421 } 422 423 define i1 @lshr5(i32 %X, i32 %Y) { 424 ; CHECK-LABEL: @lshr5( 425 %A = lshr i32 %X, %Y 426 %C = icmp ugt i32 %A, %X 427 ret i1 %C 428 ; CHECK: ret i1 false 429 } 430 431 define i1 @ashr1(i32 %x) { 432 ; CHECK-LABEL: @ashr1( 433 %s = ashr i32 -1, %x 434 %c = icmp eq i32 %s, 0 435 ret i1 %c 436 ; CHECK: ret i1 false 437 } 438 439 define i1 @ashr2(i32 %x) { 440 ; CHECK-LABEL: @ashr2( 441 %s = ashr i32 %x, 30 442 %c = icmp slt i32 %s, -5 443 ret i1 %c 444 ; CHECK: ret i1 false 445 } 446 447 define i1 @ashr3(i32 %x) { 448 ; CHECK-LABEL: @ashr3( 449 %s = ashr i32 %x, %x 450 %c = icmp eq i32 %s, 0 451 ret i1 %c 452 ; CHECK: ret i1 true 453 } 454 455 define i1 @select1(i1 %cond) { 456 ; CHECK-LABEL: @select1( 457 %s = select i1 %cond, i32 1, i32 0 458 %c = icmp eq i32 %s, 1 459 ret i1 %c 460 ; CHECK: ret i1 %cond 461 } 462 463 define i1 @select2(i1 %cond) { 464 ; CHECK-LABEL: @select2( 465 %x = zext i1 %cond to i32 466 %s = select i1 %cond, i32 %x, i32 0 467 %c = icmp ne i32 %s, 0 468 ret i1 %c 469 ; CHECK: ret i1 %cond 470 } 471 472 define i1 @select3(i1 %cond) { 473 ; CHECK-LABEL: @select3( 474 %x = zext i1 %cond to i32 475 %s = select i1 %cond, i32 1, i32 %x 476 %c = icmp ne i32 %s, 0 477 ret i1 %c 478 ; CHECK: ret i1 %cond 479 } 480 481 define i1 @select4(i1 %cond) { 482 ; CHECK-LABEL: @select4( 483 %invert = xor i1 %cond, 1 484 %s = select i1 %invert, i32 0, i32 1 485 %c = icmp ne i32 %s, 0 486 ret i1 %c 487 ; CHECK: ret i1 %cond 488 } 489 490 define i1 @select5(i32 %x) { 491 ; CHECK-LABEL: @select5( 492 %c = icmp eq i32 %x, 0 493 %s = select i1 %c, i32 1, i32 %x 494 %c2 = icmp eq i32 %s, 0 495 ret i1 %c2 496 ; CHECK: ret i1 false 497 } 498 499 define i1 @select6(i32 %x) { 500 ; CHECK-LABEL: @select6( 501 %c = icmp sgt i32 %x, 0 502 %s = select i1 %c, i32 %x, i32 4 503 %c2 = icmp eq i32 %s, 0 504 ret i1 %c2 505 ; CHECK: ret i1 %c2 506 } 507 508 define i1 @urem1(i32 %X, i32 %Y) { 509 ; CHECK-LABEL: @urem1( 510 %A = urem i32 %X, %Y 511 %B = icmp ult i32 %A, %Y 512 ret i1 %B 513 ; CHECK: ret i1 true 514 } 515 516 define i1 @urem2(i32 %X, i32 %Y) { 517 ; CHECK-LABEL: @urem2( 518 %A = urem i32 %X, %Y 519 %B = icmp eq i32 %A, %Y 520 ret i1 %B 521 ; CHECK: ret i1 false 522 } 523 524 define i1 @urem3(i32 %X) { 525 ; CHECK-LABEL: @urem3( 526 %A = urem i32 %X, 10 527 %B = icmp ult i32 %A, 15 528 ret i1 %B 529 ; CHECK: ret i1 true 530 } 531 532 define i1 @urem4(i32 %X) { 533 ; CHECK-LABEL: @urem4( 534 %A = urem i32 %X, 15 535 %B = icmp ult i32 %A, 10 536 ret i1 %B 537 ; CHECK: ret i1 %B 538 } 539 540 define i1 @urem5(i16 %X, i32 %Y) { 541 ; CHECK-LABEL: @urem5( 542 %A = zext i16 %X to i32 543 %B = urem i32 %A, %Y 544 %C = icmp slt i32 %B, %Y 545 ret i1 %C 546 ; CHECK-NOT: ret i1 true 547 } 548 549 define i1 @urem6(i32 %X, i32 %Y) { 550 ; CHECK-LABEL: @urem6( 551 %A = urem i32 %X, %Y 552 %B = icmp ugt i32 %Y, %A 553 ret i1 %B 554 ; CHECK: ret i1 true 555 } 556 557 define i1 @urem7(i32 %X) { 558 ; CHECK-LABEL: @urem7( 559 %A = urem i32 1, %X 560 %B = icmp sgt i32 %A, %X 561 ret i1 %B 562 ; CHECK-NOT: ret i1 false 563 } 564 565 define i1 @srem1(i32 %X) { 566 ; CHECK-LABEL: @srem1( 567 %A = srem i32 %X, -5 568 %B = icmp sgt i32 %A, 5 569 ret i1 %B 570 ; CHECK: ret i1 false 571 } 572 573 ; PR9343 #15 574 ; CHECK-LABEL: @srem2( 575 ; CHECK: ret i1 false 576 define i1 @srem2(i16 %X, i32 %Y) { 577 %A = zext i16 %X to i32 578 %B = add nsw i32 %A, 1 579 %C = srem i32 %B, %Y 580 %D = icmp slt i32 %C, 0 581 ret i1 %D 582 } 583 584 ; CHECK-LABEL: @srem3( 585 ; CHECK-NEXT: ret i1 false 586 define i1 @srem3(i16 %X, i32 %Y) { 587 %A = zext i16 %X to i32 588 %B = or i32 2147483648, %A 589 %C = sub nsw i32 1, %B 590 %D = srem i32 %C, %Y 591 %E = icmp slt i32 %D, 0 592 ret i1 %E 593 } 594 595 define i1 @udiv1(i32 %X) { 596 ; CHECK-LABEL: @udiv1( 597 %A = udiv i32 %X, 1000000 598 %B = icmp ult i32 %A, 5000 599 ret i1 %B 600 ; CHECK: ret i1 true 601 } 602 603 define i1 @udiv2(i32 %X, i32 %Y, i32 %Z) { 604 ; CHECK-LABEL: @udiv2( 605 %A = udiv exact i32 10, %Z 606 %B = udiv exact i32 20, %Z 607 %C = icmp ult i32 %A, %B 608 ret i1 %C 609 ; CHECK: ret i1 true 610 } 611 612 define i1 @udiv3(i32 %X, i32 %Y) { 613 ; CHECK-LABEL: @udiv3( 614 %A = udiv i32 %X, %Y 615 %C = icmp ugt i32 %A, %X 616 ret i1 %C 617 ; CHECK: ret i1 false 618 } 619 620 define i1 @udiv4(i32 %X, i32 %Y) { 621 ; CHECK-LABEL: @udiv4( 622 %A = udiv i32 %X, %Y 623 %C = icmp ule i32 %A, %X 624 ret i1 %C 625 ; CHECK: ret i1 true 626 } 627 628 define i1 @udiv5(i32 %X) { 629 ; CHECK-LABEL: @udiv5( 630 %A = udiv i32 123, %X 631 %C = icmp ugt i32 %A, 124 632 ret i1 %C 633 ; CHECK: ret i1 false 634 } 635 636 ; PR11340 637 define i1 @udiv6(i32 %X) nounwind { 638 ; CHECK-LABEL: @udiv6( 639 %A = udiv i32 1, %X 640 %C = icmp eq i32 %A, 0 641 ret i1 %C 642 ; CHECK: ret i1 %C 643 } 644 645 646 define i1 @sdiv1(i32 %X) { 647 ; CHECK-LABEL: @sdiv1( 648 %A = sdiv i32 %X, 1000000 649 %B = icmp slt i32 %A, 3000 650 ret i1 %B 651 ; CHECK: ret i1 true 652 } 653 654 define i1 @or1(i32 %X) { 655 ; CHECK-LABEL: @or1( 656 %A = or i32 %X, 62 657 %B = icmp ult i32 %A, 50 658 ret i1 %B 659 ; CHECK: ret i1 false 660 } 661 662 define i1 @and1(i32 %X) { 663 ; CHECK-LABEL: @and1( 664 %A = and i32 %X, 62 665 %B = icmp ugt i32 %A, 70 666 ret i1 %B 667 ; CHECK: ret i1 false 668 } 669 670 define i1 @mul1(i32 %X) { 671 ; CHECK-LABEL: @mul1( 672 ; Square of a non-zero number is non-zero if there is no overflow. 673 %Y = or i32 %X, 1 674 %M = mul nuw i32 %Y, %Y 675 %C = icmp eq i32 %M, 0 676 ret i1 %C 677 ; CHECK: ret i1 false 678 } 679 680 define i1 @mul2(i32 %X) { 681 ; CHECK-LABEL: @mul2( 682 ; Square of a non-zero number is positive if there is no signed overflow. 683 %Y = or i32 %X, 1 684 %M = mul nsw i32 %Y, %Y 685 %C = icmp sgt i32 %M, 0 686 ret i1 %C 687 ; CHECK: ret i1 true 688 } 689 690 define i1 @mul3(i32 %X, i32 %Y) { 691 ; CHECK-LABEL: @mul3( 692 ; Product of non-negative numbers is non-negative if there is no signed overflow. 693 %XX = mul nsw i32 %X, %X 694 %YY = mul nsw i32 %Y, %Y 695 %M = mul nsw i32 %XX, %YY 696 %C = icmp sge i32 %M, 0 697 ret i1 %C 698 ; CHECK: ret i1 true 699 } 700 701 define <2 x i1> @vectorselect1(<2 x i1> %cond) { 702 ; CHECK-LABEL: @vectorselect1( 703 %invert = xor <2 x i1> %cond, <i1 1, i1 1> 704 %s = select <2 x i1> %invert, <2 x i32> <i32 0, i32 0>, <2 x i32> <i32 1, i32 1> 705 %c = icmp ne <2 x i32> %s, <i32 0, i32 0> 706 ret <2 x i1> %c 707 ; CHECK: ret <2 x i1> %cond 708 } 709 710 ; PR11948 711 define <2 x i1> @vectorselectcrash(i32 %arg1) { 712 %tobool40 = icmp ne i32 %arg1, 0 713 %cond43 = select i1 %tobool40, <2 x i16> <i16 -5, i16 66>, <2 x i16> <i16 46, i16 1> 714 %cmp45 = icmp ugt <2 x i16> %cond43, <i16 73, i16 21> 715 ret <2 x i1> %cmp45 716 } 717 718 ; PR12013 719 define i1 @alloca_compare(i64 %idx) { 720 %sv = alloca { i32, i32, [124 x i32] } 721 %1 = getelementptr inbounds { i32, i32, [124 x i32] }, { i32, i32, [124 x i32] }* %sv, i32 0, i32 2, i64 %idx 722 %2 = icmp eq i32* %1, null 723 ret i1 %2 724 ; CHECK: alloca_compare 725 ; CHECK: ret i1 false 726 } 727 728 ; PR12075 729 define i1 @infinite_gep() { 730 ret i1 1 731 732 unreachableblock: 733 %X = getelementptr i32, i32 *%X, i32 1 734 %Y = icmp eq i32* %X, null 735 ret i1 %Y 736 } 737 738 ; It's not valid to fold a comparison of an argument with an alloca, even though 739 ; that's tempting. An argument can't *alias* an alloca, however the aliasing rule 740 ; relies on restrictions against guessing an object's address and dereferencing. 741 ; There are no restrictions against guessing an object's address and comparing. 742 743 define i1 @alloca_argument_compare(i64* %arg) { 744 %alloc = alloca i64 745 %cmp = icmp eq i64* %arg, %alloc 746 ret i1 %cmp 747 ; CHECK: alloca_argument_compare 748 ; CHECK: ret i1 %cmp 749 } 750 751 ; As above, but with the operands reversed. 752 753 define i1 @alloca_argument_compare_swapped(i64* %arg) { 754 %alloc = alloca i64 755 %cmp = icmp eq i64* %alloc, %arg 756 ret i1 %cmp 757 ; CHECK: alloca_argument_compare_swapped 758 ; CHECK: ret i1 %cmp 759 } 760 761 ; Don't assume that a noalias argument isn't equal to a global variable's 762 ; address. This is an example where AliasAnalysis' NoAlias concept is 763 ; different from actual pointer inequality. 764 765 @y = external global i32 766 define zeroext i1 @external_compare(i32* noalias %x) { 767 %cmp = icmp eq i32* %x, @y 768 ret i1 %cmp 769 ; CHECK: external_compare 770 ; CHECK: ret i1 %cmp 771 } 772 773 define i1 @alloca_gep(i64 %a, i64 %b) { 774 ; CHECK-LABEL: @alloca_gep( 775 ; We can prove this GEP is non-null because it is inbounds and the pointer 776 ; is non-null. 777 %strs = alloca [1000 x [1001 x i8]], align 16 778 %x = getelementptr inbounds [1000 x [1001 x i8]], [1000 x [1001 x i8]]* %strs, i64 0, i64 %a, i64 %b 779 %cmp = icmp eq i8* %x, null 780 ret i1 %cmp 781 ; CHECK-NEXT: ret i1 false 782 } 783 784 define i1 @non_inbounds_gep_compare(i64* %a) { 785 ; CHECK-LABEL: @non_inbounds_gep_compare( 786 ; Equality compares with non-inbounds GEPs can be folded. 787 %x = getelementptr i64, i64* %a, i64 42 788 %y = getelementptr inbounds i64, i64* %x, i64 -42 789 %z = getelementptr i64, i64* %a, i64 -42 790 %w = getelementptr inbounds i64, i64* %z, i64 42 791 %cmp = icmp eq i64* %y, %w 792 ret i1 %cmp 793 ; CHECK-NEXT: ret i1 true 794 } 795 796 define i1 @non_inbounds_gep_compare2(i64* %a) { 797 ; CHECK-LABEL: @non_inbounds_gep_compare2( 798 ; Equality compares with non-inbounds GEPs can be folded. 799 %x = getelementptr i64, i64* %a, i64 4294967297 800 %y = getelementptr i64, i64* %a, i64 1 801 %cmp = icmp eq i64* %y, %y 802 ret i1 %cmp 803 ; CHECK-NEXT: ret i1 true 804 } 805 806 define <4 x i8> @vectorselectfold(<4 x i8> %a, <4 x i8> %b) { 807 %false = icmp ne <4 x i8> zeroinitializer, zeroinitializer 808 %sel = select <4 x i1> %false, <4 x i8> %a, <4 x i8> %b 809 ret <4 x i8> %sel 810 811 ; CHECK-LABEL: @vectorselectfold 812 ; CHECK-NEXT: ret <4 x i8> %b 813 } 814 815 define <4 x i8> @vectorselectfold2(<4 x i8> %a, <4 x i8> %b) { 816 %true = icmp eq <4 x i8> zeroinitializer, zeroinitializer 817 %sel = select <4 x i1> %true, <4 x i8> %a, <4 x i8> %b 818 ret <4 x i8> %sel 819 820 ; CHECK-LABEL: @vectorselectfold 821 ; CHECK-NEXT: ret <4 x i8> %a 822 } 823 824 define i1 @compare_always_true_slt(i16 %a) { 825 %1 = zext i16 %a to i32 826 %2 = sub nsw i32 0, %1 827 %3 = icmp slt i32 %2, 1 828 ret i1 %3 829 830 ; CHECK-LABEL: @compare_always_true_slt 831 ; CHECK-NEXT: ret i1 true 832 } 833 834 define i1 @compare_always_true_sle(i16 %a) { 835 %1 = zext i16 %a to i32 836 %2 = sub nsw i32 0, %1 837 %3 = icmp sle i32 %2, 0 838 ret i1 %3 839 840 ; CHECK-LABEL: @compare_always_true_sle 841 ; CHECK-NEXT: ret i1 true 842 } 843 844 define i1 @compare_always_false_sgt(i16 %a) { 845 %1 = zext i16 %a to i32 846 %2 = sub nsw i32 0, %1 847 %3 = icmp sgt i32 %2, 0 848 ret i1 %3 849 850 ; CHECK-LABEL: @compare_always_false_sgt 851 ; CHECK-NEXT: ret i1 false 852 } 853 854 define i1 @compare_always_false_sge(i16 %a) { 855 %1 = zext i16 %a to i32 856 %2 = sub nsw i32 0, %1 857 %3 = icmp sge i32 %2, 1 858 ret i1 %3 859 860 ; CHECK-LABEL: @compare_always_false_sge 861 ; CHECK-NEXT: ret i1 false 862 } 863 864 define i1 @compare_always_false_eq(i16 %a) { 865 %1 = zext i16 %a to i32 866 %2 = sub nsw i32 0, %1 867 %3 = icmp eq i32 %2, 1 868 ret i1 %3 869 870 ; CHECK-LABEL: @compare_always_false_eq 871 ; CHECK-NEXT: ret i1 false 872 } 873 874 define i1 @compare_always_false_ne(i16 %a) { 875 %1 = zext i16 %a to i32 876 %2 = sub nsw i32 0, %1 877 %3 = icmp ne i32 %2, 1 878 ret i1 %3 879 880 ; CHECK-LABEL: @compare_always_false_ne 881 ; CHECK-NEXT: ret i1 true 882 } 883 884 define i1 @compare_dividend(i32 %a) { 885 %div = sdiv i32 2, %a 886 %cmp = icmp eq i32 %div, 3 887 ret i1 %cmp 888 889 ; CHECK-LABEL: @compare_dividend 890 ; CHECK-NEXT: ret i1 false 891 } 892 893 define i1 @lshr_ugt_false(i32 %a) { 894 %shr = lshr i32 1, %a 895 %cmp = icmp ugt i32 %shr, 1 896 ret i1 %cmp 897 ; CHECK-LABEL: @lshr_ugt_false 898 ; CHECK-NEXT: ret i1 false 899 } 900 901 define i1 @exact_lshr_ugt_false(i32 %a) { 902 %shr = lshr exact i32 30, %a 903 %cmp = icmp ult i32 %shr, 15 904 ret i1 %cmp 905 ; CHECK-LABEL: @exact_lshr_ugt_false 906 ; CHECK-NEXT: ret i1 false 907 } 908 909 define i1 @lshr_sgt_false(i32 %a) { 910 %shr = lshr i32 1, %a 911 %cmp = icmp sgt i32 %shr, 1 912 ret i1 %cmp 913 ; CHECK-LABEL: @lshr_sgt_false 914 ; CHECK-NEXT: ret i1 false 915 } 916 917 define i1 @ashr_sgt_false(i32 %a) { 918 %shr = ashr i32 -30, %a 919 %cmp = icmp sgt i32 %shr, -1 920 ret i1 %cmp 921 ; CHECK-LABEL: @ashr_sgt_false 922 ; CHECK-NEXT: ret i1 false 923 } 924 925 define i1 @exact_ashr_sgt_false(i32 %a) { 926 %shr = ashr exact i32 -30, %a 927 %cmp = icmp sgt i32 %shr, -15 928 ret i1 %cmp 929 ; CHECK-LABEL: @exact_ashr_sgt_false 930 ; CHECK-NEXT: ret i1 false 931 } 932 933 define i1 @nonnull_arg(i32* nonnull %i) { 934 %cmp = icmp eq i32* %i, null 935 ret i1 %cmp 936 ; CHECK-LABEL: @nonnull_arg 937 ; CHECK: ret i1 false 938 } 939 940 define i1 @nonnull_deref_arg(i32* dereferenceable(4) %i) { 941 %cmp = icmp eq i32* %i, null 942 ret i1 %cmp 943 ; CHECK-LABEL: @nonnull_deref_arg 944 ; CHECK: ret i1 false 945 } 946 947 define i1 @nonnull_deref_as_arg(i32 addrspace(1)* dereferenceable(4) %i) { 948 %cmp = icmp eq i32 addrspace(1)* %i, null 949 ret i1 %cmp 950 ; CHECK-LABEL: @nonnull_deref_as_arg 951 ; CHECK: icmp 952 ; CHECK: ret 953 } 954 955 declare nonnull i32* @returns_nonnull_helper() 956 define i1 @returns_nonnull() { 957 %call = call nonnull i32* @returns_nonnull_helper() 958 %cmp = icmp eq i32* %call, null 959 ret i1 %cmp 960 ; CHECK-LABEL: @returns_nonnull 961 ; CHECK: ret i1 false 962 } 963 964 declare dereferenceable(4) i32* @returns_nonnull_deref_helper() 965 define i1 @returns_nonnull_deref() { 966 %call = call dereferenceable(4) i32* @returns_nonnull_deref_helper() 967 %cmp = icmp eq i32* %call, null 968 ret i1 %cmp 969 ; CHECK-LABEL: @returns_nonnull_deref 970 ; CHECK: ret i1 false 971 } 972 973 declare dereferenceable(4) i32 addrspace(1)* @returns_nonnull_deref_as_helper() 974 define i1 @returns_nonnull_as_deref() { 975 %call = call dereferenceable(4) i32 addrspace(1)* @returns_nonnull_deref_as_helper() 976 %cmp = icmp eq i32 addrspace(1)* %call, null 977 ret i1 %cmp 978 ; CHECK-LABEL: @returns_nonnull_as_deref 979 ; CHECK: icmp 980 ; CHECK: ret 981 } 982 983 define i1 @nonnull_load(i32** %addr) { 984 %ptr = load i32*, i32** %addr, !nonnull !{} 985 %cmp = icmp eq i32* %ptr, null 986 ret i1 %cmp 987 ; CHECK-LABEL: @nonnull_load 988 ; CHECK: ret i1 false 989 } 990 991 define i1 @nonnull_load_as_outer(i32* addrspace(1)* %addr) { 992 %ptr = load i32*, i32* addrspace(1)* %addr, !nonnull !{} 993 %cmp = icmp eq i32* %ptr, null 994 ret i1 %cmp 995 ; CHECK-LABEL: @nonnull_load_as_outer 996 ; CHECK: ret i1 false 997 } 998 define i1 @nonnull_load_as_inner(i32 addrspace(1)** %addr) { 999 %ptr = load i32 addrspace(1)*, i32 addrspace(1)** %addr, !nonnull !{} 1000 %cmp = icmp eq i32 addrspace(1)* %ptr, null 1001 ret i1 %cmp 1002 ; CHECK-LABEL: @nonnull_load_as_inner 1003 ; CHECK: ret i1 false 1004 } 1005 1006 ; If a bit is known to be zero for A and known to be one for B, 1007 ; then A and B cannot be equal. 1008 define i1 @icmp_eq_const(i32 %a) nounwind { 1009 %b = mul nsw i32 %a, -2 1010 %c = icmp eq i32 %b, 1 1011 ret i1 %c 1012 1013 ; CHECK-LABEL: @icmp_eq_const 1014 ; CHECK-NEXT: ret i1 false 1015 } 1016 1017 define i1 @icmp_ne_const(i32 %a) nounwind { 1018 %b = mul nsw i32 %a, -2 1019 %c = icmp ne i32 %b, 1 1020 ret i1 %c 1021 1022 ; CHECK-LABEL: @icmp_ne_const 1023 ; CHECK-NEXT: ret i1 true 1024 } 1025 1026 define i1 @icmp_sdiv_int_min(i32 %a) { 1027 %div = sdiv i32 -2147483648, %a 1028 %cmp = icmp ne i32 %div, -1073741824 1029 ret i1 %cmp 1030 1031 ; CHECK-LABEL: @icmp_sdiv_int_min 1032 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 -2147483648, %a 1033 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[DIV]], -1073741824 1034 ; CHECK-NEXT: ret i1 [[CMP]] 1035 } 1036 1037 define i1 @icmp_sdiv_pr20288(i64 %a) { 1038 %div = sdiv i64 %a, -8589934592 1039 %cmp = icmp ne i64 %div, 1073741824 1040 ret i1 %cmp 1041 1042 ; CHECK-LABEL: @icmp_sdiv_pr20288 1043 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 %a, -8589934592 1044 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[DIV]], 1073741824 1045 ; CHECK-NEXT: ret i1 [[CMP]] 1046 } 1047 1048 define i1 @icmp_sdiv_neg1(i64 %a) { 1049 %div = sdiv i64 %a, -1 1050 %cmp = icmp ne i64 %div, 1073741824 1051 ret i1 %cmp 1052 1053 ; CHECK-LABEL: @icmp_sdiv_neg1 1054 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 %a, -1 1055 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[DIV]], 1073741824 1056 ; CHECK-NEXT: ret i1 [[CMP]] 1057 } 1058 1059 define i1 @icmp_known_bits(i4 %x, i4 %y) { 1060 %and1 = and i4 %y, -7 1061 %and2 = and i4 %x, -7 1062 %or1 = or i4 %and1, 2 1063 %or2 = or i4 %and2, 2 1064 %add = add i4 %or1, %or2 1065 %cmp = icmp eq i4 %add, 0 1066 ret i1 %cmp 1067 1068 ; CHECK-LABEL: @icmp_known_bits 1069 ; CHECK-NEXT: ret i1 false 1070 } 1071 1072 define i1 @icmp_shl_nuw_1(i64 %a) { 1073 %shl = shl nuw i64 1, %a 1074 %cmp = icmp ne i64 %shl, 0 1075 ret i1 %cmp 1076 1077 ; CHECK-LABEL: @icmp_shl_nuw_1 1078 ; CHECK-NEXT: ret i1 true 1079 } 1080 1081 define i1 @icmp_shl_nsw_neg1(i64 %a) { 1082 %shl = shl nsw i64 -1, %a 1083 %cmp = icmp sge i64 %shl, 3 1084 ret i1 %cmp 1085 1086 ; CHECK-LABEL: @icmp_shl_nsw_neg1 1087 ; CHECK-NEXT: ret i1 false 1088 } 1089 1090 define i1 @icmp_shl_nsw_1(i64 %a) { 1091 %shl = shl nsw i64 1, %a 1092 %cmp = icmp sge i64 %shl, 0 1093 ret i1 %cmp 1094 1095 ; CHECK-LABEL: @icmp_shl_nsw_1 1096 ; CHECK-NEXT: ret i1 true 1097 } 1098 1099 define i1 @icmp_shl_1_V_ugt_2147483648(i32 %V) { 1100 %shl = shl i32 1, %V 1101 %cmp = icmp ugt i32 %shl, 2147483648 1102 ret i1 %cmp 1103 1104 ; CHECK-LABEL: @icmp_shl_1_V_ugt_2147483648( 1105 ; CHECK-NEXT: ret i1 false 1106 } 1107 1108 define i1 @icmp_shl_1_V_ule_2147483648(i32 %V) { 1109 %shl = shl i32 1, %V 1110 %cmp = icmp ule i32 %shl, 2147483648 1111 ret i1 %cmp 1112 1113 ; CHECK-LABEL: @icmp_shl_1_V_ule_2147483648( 1114 ; CHECK-NEXT: ret i1 true 1115 } 1116 1117 define i1 @icmp_shl_1_V_eq_31(i32 %V) { 1118 %shl = shl i32 1, %V 1119 %cmp = icmp eq i32 %shl, 31 1120 ret i1 %cmp 1121 1122 ; CHECK-LABEL: @icmp_shl_1_V_eq_31( 1123 ; CHECK-NEXT: ret i1 false 1124 } 1125 1126 define i1 @icmp_shl_1_V_ne_31(i32 %V) { 1127 %shl = shl i32 1, %V 1128 %cmp = icmp ne i32 %shl, 31 1129 ret i1 %cmp 1130 1131 ; CHECK-LABEL: @icmp_shl_1_V_ne_31( 1132 ; CHECK-NEXT: ret i1 true 1133 } 1134 1135 define i1 @tautological1(i32 %A, i32 %B) { 1136 %C = and i32 %A, %B 1137 %D = icmp ugt i32 %C, %A 1138 ret i1 %D 1139 ; CHECK-LABEL: @tautological1( 1140 ; CHECK: ret i1 false 1141 } 1142 1143 define i1 @tautological2(i32 %A, i32 %B) { 1144 %C = and i32 %A, %B 1145 %D = icmp ule i32 %C, %A 1146 ret i1 %D 1147 ; CHECK-LABEL: @tautological2( 1148 ; CHECK: ret i1 true 1149 } 1150 1151 define i1 @tautological3(i32 %A, i32 %B) { 1152 %C = or i32 %A, %B 1153 %D = icmp ule i32 %A, %C 1154 ret i1 %D 1155 ; CHECK-LABEL: @tautological3( 1156 ; CHECK: ret i1 true 1157 } 1158 1159 define i1 @tautological4(i32 %A, i32 %B) { 1160 %C = or i32 %A, %B 1161 %D = icmp ugt i32 %A, %C 1162 ret i1 %D 1163 ; CHECK-LABEL: @tautological4( 1164 ; CHECK: ret i1 false 1165 } 1166 1167 define i1 @tautological5(i32 %A, i32 %B) { 1168 %C = or i32 %A, %B 1169 %D = icmp ult i32 %C, %A 1170 ret i1 %D 1171 ; CHECK-LABEL: @tautological5( 1172 ; CHECK: ret i1 false 1173 } 1174 1175 define i1 @tautological6(i32 %A, i32 %B) { 1176 %C = or i32 %A, %B 1177 %D = icmp uge i32 %C, %A 1178 ret i1 %D 1179 ; CHECK-LABEL: @tautological6( 1180 ; CHECK: ret i1 true 1181 } 1182 1183 define i1 @tautological7(i32 %A, i32 %B) { 1184 %C = and i32 %A, %B 1185 %D = icmp uge i32 %A, %C 1186 ret i1 %D 1187 ; CHECK-LABEL: @tautological7( 1188 ; CHECK: ret i1 true 1189 } 1190 1191 define i1 @tautological8(i32 %A, i32 %B) { 1192 %C = and i32 %A, %B 1193 %D = icmp ult i32 %A, %C 1194 ret i1 %D 1195 ; CHECK-LABEL: @tautological8( 1196 ; CHECK: ret i1 false 1197 } 1198 1199 define i1 @tautological9(i32 %x) { 1200 %add = add nuw i32 %x, 13 1201 %cmp = icmp ne i32 %add, 12 1202 ret i1 %cmp 1203 ; CHECK-LABEL: @tautological9( 1204 ; CHECK: ret i1 true 1205 } 1206 1207 declare void @helper_i1(i1) 1208 ; Series of tests for icmp s[lt|ge] (or A, B), A and icmp s[gt|le] A, (or A, B) 1209 define void @icmp_slt_sge_or(i32 %Ax, i32 %Bx) { 1210 ; 'p' for positive, 'n' for negative, 'x' for potentially either. 1211 ; %D is 'icmp slt (or A, B), A' 1212 ; %E is 'icmp sge (or A, B), A' making it the not of %D 1213 ; %F is 'icmp sgt A, (or A, B)' making it the same as %D 1214 ; %G is 'icmp sle A, (or A, B)' making it the not of %D 1215 %Aneg = or i32 %Ax, 2147483648 1216 %Apos = and i32 %Ax, 2147483647 1217 %Bneg = or i32 %Bx, 2147483648 1218 %Bpos = and i32 %Bx, 2147483647 1219 1220 %Cpp = or i32 %Apos, %Bpos 1221 %Dpp = icmp slt i32 %Cpp, %Apos 1222 %Epp = icmp sge i32 %Cpp, %Apos 1223 %Fpp = icmp sgt i32 %Apos, %Cpp 1224 %Gpp = icmp sle i32 %Apos, %Cpp 1225 %Cpx = or i32 %Apos, %Bx 1226 %Dpx = icmp slt i32 %Cpx, %Apos 1227 %Epx = icmp sge i32 %Cpx, %Apos 1228 %Fpx = icmp sgt i32 %Apos, %Cpx 1229 %Gpx = icmp sle i32 %Apos, %Cpx 1230 %Cpn = or i32 %Apos, %Bneg 1231 %Dpn = icmp slt i32 %Cpn, %Apos 1232 %Epn = icmp sge i32 %Cpn, %Apos 1233 %Fpn = icmp sgt i32 %Apos, %Cpn 1234 %Gpn = icmp sle i32 %Apos, %Cpn 1235 1236 %Cxp = or i32 %Ax, %Bpos 1237 %Dxp = icmp slt i32 %Cxp, %Ax 1238 %Exp = icmp sge i32 %Cxp, %Ax 1239 %Fxp = icmp sgt i32 %Ax, %Cxp 1240 %Gxp = icmp sle i32 %Ax, %Cxp 1241 %Cxx = or i32 %Ax, %Bx 1242 %Dxx = icmp slt i32 %Cxx, %Ax 1243 %Exx = icmp sge i32 %Cxx, %Ax 1244 %Fxx = icmp sgt i32 %Ax, %Cxx 1245 %Gxx = icmp sle i32 %Ax, %Cxx 1246 %Cxn = or i32 %Ax, %Bneg 1247 %Dxn = icmp slt i32 %Cxn, %Ax 1248 %Exn = icmp sge i32 %Cxn, %Ax 1249 %Fxn = icmp sgt i32 %Ax, %Cxn 1250 %Gxn = icmp sle i32 %Ax, %Cxn 1251 1252 %Cnp = or i32 %Aneg, %Bpos 1253 %Dnp = icmp slt i32 %Cnp, %Aneg 1254 %Enp = icmp sge i32 %Cnp, %Aneg 1255 %Fnp = icmp sgt i32 %Aneg, %Cnp 1256 %Gnp = icmp sle i32 %Aneg, %Cnp 1257 %Cnx = or i32 %Aneg, %Bx 1258 %Dnx = icmp slt i32 %Cnx, %Aneg 1259 %Enx = icmp sge i32 %Cnx, %Aneg 1260 %Fnx = icmp sgt i32 %Aneg, %Cnx 1261 %Gnx = icmp sle i32 %Aneg, %Cnx 1262 %Cnn = or i32 %Aneg, %Bneg 1263 %Dnn = icmp slt i32 %Cnn, %Aneg 1264 %Enn = icmp sge i32 %Cnn, %Aneg 1265 %Fnn = icmp sgt i32 %Aneg, %Cnn 1266 %Gnn = icmp sle i32 %Aneg, %Cnn 1267 1268 call void @helper_i1(i1 %Dpp) 1269 call void @helper_i1(i1 %Epp) 1270 call void @helper_i1(i1 %Fpp) 1271 call void @helper_i1(i1 %Gpp) 1272 call void @helper_i1(i1 %Dpx) 1273 call void @helper_i1(i1 %Epx) 1274 call void @helper_i1(i1 %Fpx) 1275 call void @helper_i1(i1 %Gpx) 1276 call void @helper_i1(i1 %Dpn) 1277 call void @helper_i1(i1 %Epn) 1278 call void @helper_i1(i1 %Fpn) 1279 call void @helper_i1(i1 %Gpn) 1280 call void @helper_i1(i1 %Dxp) 1281 call void @helper_i1(i1 %Exp) 1282 call void @helper_i1(i1 %Fxp) 1283 call void @helper_i1(i1 %Gxp) 1284 call void @helper_i1(i1 %Dxx) 1285 call void @helper_i1(i1 %Exx) 1286 call void @helper_i1(i1 %Fxx) 1287 call void @helper_i1(i1 %Gxx) 1288 call void @helper_i1(i1 %Dxn) 1289 call void @helper_i1(i1 %Exn) 1290 call void @helper_i1(i1 %Fxn) 1291 call void @helper_i1(i1 %Gxn) 1292 call void @helper_i1(i1 %Dnp) 1293 call void @helper_i1(i1 %Enp) 1294 call void @helper_i1(i1 %Fnp) 1295 call void @helper_i1(i1 %Gnp) 1296 call void @helper_i1(i1 %Dnx) 1297 call void @helper_i1(i1 %Enx) 1298 call void @helper_i1(i1 %Fnx) 1299 call void @helper_i1(i1 %Gnx) 1300 call void @helper_i1(i1 %Dnn) 1301 call void @helper_i1(i1 %Enn) 1302 call void @helper_i1(i1 %Fnn) 1303 call void @helper_i1(i1 %Gnn) 1304 ; CHECK-LABEL: @icmp_slt_sge_or 1305 ; CHECK: call void @helper_i1(i1 false) 1306 ; CHECK: call void @helper_i1(i1 true) 1307 ; CHECK: call void @helper_i1(i1 false) 1308 ; CHECK: call void @helper_i1(i1 true) 1309 ; CHECK: call void @helper_i1(i1 %Dpx) 1310 ; CHECK: call void @helper_i1(i1 %Epx) 1311 ; CHECK: call void @helper_i1(i1 %Fpx) 1312 ; CHECK: call void @helper_i1(i1 %Gpx) 1313 ; CHECK: call void @helper_i1(i1 true) 1314 ; CHECK: call void @helper_i1(i1 false) 1315 ; CHECK: call void @helper_i1(i1 true) 1316 ; CHECK: call void @helper_i1(i1 false) 1317 ; CHECK: call void @helper_i1(i1 false) 1318 ; CHECK: call void @helper_i1(i1 true) 1319 ; CHECK: call void @helper_i1(i1 false) 1320 ; CHECK: call void @helper_i1(i1 true) 1321 ; CHECK: call void @helper_i1(i1 %Dxx) 1322 ; CHECK: call void @helper_i1(i1 %Exx) 1323 ; CHECK: call void @helper_i1(i1 %Fxx) 1324 ; CHECK: call void @helper_i1(i1 %Gxx) 1325 ; CHECK: call void @helper_i1(i1 %Dxn) 1326 ; CHECK: call void @helper_i1(i1 %Exn) 1327 ; CHECK: call void @helper_i1(i1 %Fxn) 1328 ; CHECK: call void @helper_i1(i1 %Gxn) 1329 ; CHECK: call void @helper_i1(i1 false) 1330 ; CHECK: call void @helper_i1(i1 true) 1331 ; CHECK: call void @helper_i1(i1 false) 1332 ; CHECK: call void @helper_i1(i1 true) 1333 ; CHECK: call void @helper_i1(i1 false) 1334 ; CHECK: call void @helper_i1(i1 true) 1335 ; CHECK: call void @helper_i1(i1 false) 1336 ; CHECK: call void @helper_i1(i1 true) 1337 ; CHECK: call void @helper_i1(i1 false) 1338 ; CHECK: call void @helper_i1(i1 true) 1339 ; CHECK: call void @helper_i1(i1 false) 1340 ; CHECK: call void @helper_i1(i1 true) 1341 ret void 1342 } 1343