1; RUN: opt < %s -instsimplify -S | FileCheck %s 2target datalayout = "p:32:32" 3 4define 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 13define 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 24define i1 @gep() { 25; CHECK-LABEL: @gep( 26 %a = alloca [3 x i8], align 8 27 %x = getelementptr inbounds [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 33define i1 @gep2() { 34; CHECK-LABEL: @gep2( 35 %a = alloca [3 x i8], align 8 36 %x = getelementptr inbounds [3 x i8]* %a, i32 0, i32 0 37 %y = getelementptr inbounds [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 48define i1 @gep3() { 49; CHECK-LABEL: @gep3( 50 %x = alloca %gept, align 8 51 %a = getelementptr %gept* %x, i64 0, i32 0 52 %b = getelementptr %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 58define i1 @gep4() { 59; CHECK-LABEL: @gep4( 60 %x = alloca %gept, align 8 61 %a = getelementptr %gept* @gepy, i64 0, i32 0 62 %b = getelementptr %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 68define i1 @gep5() { 69; CHECK-LABEL: @gep5( 70 %x = alloca %gept, align 8 71 %a = getelementptr inbounds %gept* %x, i64 0, i32 1 72 %b = getelementptr %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 78define i1 @gep6(%gept* %x) { 79; Same as @gep3 but potentially null. 80; CHECK-LABEL: @gep6( 81 %a = getelementptr %gept* %x, i64 0, i32 0 82 %b = getelementptr %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 88define i1 @gep7(%gept* %x) { 89; CHECK-LABEL: @gep7( 90 %a = getelementptr %gept* %x, i64 0, i32 0 91 %b = getelementptr %gept* @gepz, i64 0, i32 0 92 %equal = icmp eq i32* %a, %b 93 ret i1 %equal 94; CHECK: ret i1 %equal 95} 96 97define i1 @gep8(%gept* %x) { 98; CHECK-LABEL: @gep8( 99 %a = getelementptr %gept* %x, i32 1 100 %b = getelementptr %gept* %x, i32 -1 101 %equal = icmp ugt %gept* %a, %b 102 ret i1 %equal 103; CHECK: ret i1 %equal 104} 105 106define i1 @gep9(i8* %ptr) { 107; CHECK-LABEL: @gep9( 108; CHECK-NOT: ret 109; CHECK: ret i1 true 110 111entry: 112 %first1 = getelementptr inbounds i8* %ptr, i32 0 113 %first2 = getelementptr inbounds i8* %first1, i32 1 114 %first3 = getelementptr inbounds i8* %first2, i32 2 115 %first4 = getelementptr inbounds i8* %first3, i32 4 116 %last1 = getelementptr inbounds i8* %first2, i32 48 117 %last2 = getelementptr inbounds i8* %last1, i32 8 118 %last3 = getelementptr inbounds i8* %last2, i32 -4 119 %last4 = getelementptr inbounds 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 126define i1 @gep10(i8* %ptr) { 127; CHECK-LABEL: @gep10( 128; CHECK-NOT: ret 129; CHECK: ret i1 true 130 131entry: 132 %first1 = getelementptr inbounds i8* %ptr, i32 -2 133 %first2 = getelementptr inbounds i8* %first1, i32 44 134 %last1 = getelementptr inbounds i8* %ptr, i32 48 135 %last2 = getelementptr inbounds 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 142define i1 @gep11(i8* %ptr) { 143; CHECK-LABEL: @gep11( 144; CHECK-NOT: ret 145; CHECK: ret i1 true 146 147entry: 148 %first1 = getelementptr inbounds i8* %ptr, i32 -2 149 %last1 = getelementptr inbounds i8* %ptr, i32 48 150 %last2 = getelementptr inbounds i8* %last1, i32 -6 151 %cmp = icmp ult i8* %first1, %last2 152 ret i1 %cmp 153} 154 155define i1 @gep12(i8* %ptr) { 156; CHECK-LABEL: @gep12( 157; CHECK-NOT: ret 158; CHECK: ret i1 %cmp 159 160entry: 161 %first1 = getelementptr inbounds i8* %ptr, i32 -2 162 %last1 = getelementptr inbounds i8* %ptr, i32 48 163 %last2 = getelementptr inbounds i8* %last1, i32 -6 164 %cmp = icmp slt i8* %first1, %last2 165 ret i1 %cmp 166} 167 168define 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* %ptr, i32 1 172 %cmp = icmp eq i8* %x, null 173 ret i1 %cmp 174; CHECK-NEXT: ret i1 false 175} 176 177define 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 }* %ptr, i32 0, i32 1 182 %cmp = icmp eq i8* %x, null 183 ret i1 %cmp 184; CHECK-NOT: ret i1 false 185} 186 187define 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}]}* %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 197define 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* %ptr, i32 %b 203 %cmp = icmp eq i8* %x, null 204 ret i1 %cmp 205; CHECK-NEXT: ret i1 false 206} 207 208define 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 217define 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 225define 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 233define 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 242define 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 250define 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 258define 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 269define 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 279define 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 289define 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 299define 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 309define 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 318define 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 328define 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 336define i1 @shl(i32 %x) { 337; CHECK-LABEL: @shl( 338 %s = shl i32 1, %x 339 %c = icmp eq i32 %s, 0 340 ret i1 %c 341; CHECK: ret i1 false 342} 343 344define i1 @lshr1(i32 %x) { 345; CHECK-LABEL: @lshr1( 346 %s = lshr i32 -1, %x 347 %c = icmp eq i32 %s, 0 348 ret i1 %c 349; CHECK: ret i1 false 350} 351 352define i1 @lshr2(i32 %x) { 353; CHECK-LABEL: @lshr2( 354 %s = lshr i32 %x, 30 355 %c = icmp ugt i32 %s, 8 356 ret i1 %c 357; CHECK: ret i1 false 358} 359 360define i1 @lshr3(i32 %x) { 361; CHECK-LABEL: @lshr3( 362 %s = lshr i32 %x, %x 363 %c = icmp eq i32 %s, 0 364 ret i1 %c 365; CHECK: ret i1 true 366} 367 368define i1 @ashr1(i32 %x) { 369; CHECK-LABEL: @ashr1( 370 %s = ashr i32 -1, %x 371 %c = icmp eq i32 %s, 0 372 ret i1 %c 373; CHECK: ret i1 false 374} 375 376define i1 @ashr2(i32 %x) { 377; CHECK-LABEL: @ashr2( 378 %s = ashr i32 %x, 30 379 %c = icmp slt i32 %s, -5 380 ret i1 %c 381; CHECK: ret i1 false 382} 383 384define i1 @ashr3(i32 %x) { 385; CHECK-LABEL: @ashr3( 386 %s = ashr i32 %x, %x 387 %c = icmp eq i32 %s, 0 388 ret i1 %c 389; CHECK: ret i1 true 390} 391 392define i1 @select1(i1 %cond) { 393; CHECK-LABEL: @select1( 394 %s = select i1 %cond, i32 1, i32 0 395 %c = icmp eq i32 %s, 1 396 ret i1 %c 397; CHECK: ret i1 %cond 398} 399 400define i1 @select2(i1 %cond) { 401; CHECK-LABEL: @select2( 402 %x = zext i1 %cond to i32 403 %s = select i1 %cond, i32 %x, i32 0 404 %c = icmp ne i32 %s, 0 405 ret i1 %c 406; CHECK: ret i1 %cond 407} 408 409define i1 @select3(i1 %cond) { 410; CHECK-LABEL: @select3( 411 %x = zext i1 %cond to i32 412 %s = select i1 %cond, i32 1, i32 %x 413 %c = icmp ne i32 %s, 0 414 ret i1 %c 415; CHECK: ret i1 %cond 416} 417 418define i1 @select4(i1 %cond) { 419; CHECK-LABEL: @select4( 420 %invert = xor i1 %cond, 1 421 %s = select i1 %invert, i32 0, i32 1 422 %c = icmp ne i32 %s, 0 423 ret i1 %c 424; CHECK: ret i1 %cond 425} 426 427define i1 @select5(i32 %x) { 428; CHECK-LABEL: @select5( 429 %c = icmp eq i32 %x, 0 430 %s = select i1 %c, i32 1, i32 %x 431 %c2 = icmp eq i32 %s, 0 432 ret i1 %c2 433; CHECK: ret i1 false 434} 435 436define i1 @select6(i32 %x) { 437; CHECK-LABEL: @select6( 438 %c = icmp sgt i32 %x, 0 439 %s = select i1 %c, i32 %x, i32 4 440 %c2 = icmp eq i32 %s, 0 441 ret i1 %c2 442; CHECK: ret i1 %c2 443} 444 445define i1 @urem1(i32 %X, i32 %Y) { 446; CHECK-LABEL: @urem1( 447 %A = urem i32 %X, %Y 448 %B = icmp ult i32 %A, %Y 449 ret i1 %B 450; CHECK: ret i1 true 451} 452 453define i1 @urem2(i32 %X, i32 %Y) { 454; CHECK-LABEL: @urem2( 455 %A = urem i32 %X, %Y 456 %B = icmp eq i32 %A, %Y 457 ret i1 %B 458; CHECK: ret i1 false 459} 460 461define i1 @urem3(i32 %X) { 462; CHECK-LABEL: @urem3( 463 %A = urem i32 %X, 10 464 %B = icmp ult i32 %A, 15 465 ret i1 %B 466; CHECK: ret i1 true 467} 468 469define i1 @urem4(i32 %X) { 470; CHECK-LABEL: @urem4( 471 %A = urem i32 %X, 15 472 %B = icmp ult i32 %A, 10 473 ret i1 %B 474; CHECK: ret i1 %B 475} 476 477define i1 @urem5(i16 %X, i32 %Y) { 478; CHECK-LABEL: @urem5( 479 %A = zext i16 %X to i32 480 %B = urem i32 %A, %Y 481 %C = icmp slt i32 %B, %Y 482 ret i1 %C 483; CHECK-NOT: ret i1 true 484} 485 486define i1 @urem6(i32 %X, i32 %Y) { 487; CHECK-LABEL: @urem6( 488 %A = urem i32 %X, %Y 489 %B = icmp ugt i32 %Y, %A 490 ret i1 %B 491; CHECK: ret i1 true 492} 493 494define i1 @urem7(i32 %X) { 495; CHECK-LABEL: @urem7( 496 %A = urem i32 1, %X 497 %B = icmp sgt i32 %A, %X 498 ret i1 %B 499; CHECK-NOT: ret i1 false 500} 501 502define i1 @srem1(i32 %X) { 503; CHECK-LABEL: @srem1( 504 %A = srem i32 %X, -5 505 %B = icmp sgt i32 %A, 5 506 ret i1 %B 507; CHECK: ret i1 false 508} 509 510; PR9343 #15 511; CHECK-LABEL: @srem2( 512; CHECK: ret i1 false 513define i1 @srem2(i16 %X, i32 %Y) { 514 %A = zext i16 %X to i32 515 %B = add nsw i32 %A, 1 516 %C = srem i32 %B, %Y 517 %D = icmp slt i32 %C, 0 518 ret i1 %D 519} 520 521; CHECK-LABEL: @srem3( 522; CHECK-NEXT: ret i1 false 523define i1 @srem3(i16 %X, i32 %Y) { 524 %A = zext i16 %X to i32 525 %B = or i32 2147483648, %A 526 %C = sub nsw i32 1, %B 527 %D = srem i32 %C, %Y 528 %E = icmp slt i32 %D, 0 529 ret i1 %E 530} 531 532define i1 @udiv1(i32 %X) { 533; CHECK-LABEL: @udiv1( 534 %A = udiv i32 %X, 1000000 535 %B = icmp ult i32 %A, 5000 536 ret i1 %B 537; CHECK: ret i1 true 538} 539 540define i1 @udiv2(i32 %X, i32 %Y, i32 %Z) { 541; CHECK-LABEL: @udiv2( 542 %A = udiv exact i32 10, %Z 543 %B = udiv exact i32 20, %Z 544 %C = icmp ult i32 %A, %B 545 ret i1 %C 546; CHECK: ret i1 true 547} 548 549define i1 @udiv3(i32 %X, i32 %Y) { 550; CHECK-LABEL: @udiv3( 551 %A = udiv i32 %X, %Y 552 %C = icmp ugt i32 %A, %X 553 ret i1 %C 554; CHECK: ret i1 false 555} 556 557define i1 @udiv4(i32 %X, i32 %Y) { 558; CHECK-LABEL: @udiv4( 559 %A = udiv i32 %X, %Y 560 %C = icmp ule i32 %A, %X 561 ret i1 %C 562; CHECK: ret i1 true 563} 564 565define i1 @udiv5(i32 %X) { 566; CHECK-LABEL: @udiv5( 567 %A = udiv i32 123, %X 568 %C = icmp ugt i32 %A, 124 569 ret i1 %C 570; CHECK: ret i1 false 571} 572 573; PR11340 574define i1 @udiv6(i32 %X) nounwind { 575; CHECK-LABEL: @udiv6( 576 %A = udiv i32 1, %X 577 %C = icmp eq i32 %A, 0 578 ret i1 %C 579; CHECK: ret i1 %C 580} 581 582 583define i1 @sdiv1(i32 %X) { 584; CHECK-LABEL: @sdiv1( 585 %A = sdiv i32 %X, 1000000 586 %B = icmp slt i32 %A, 3000 587 ret i1 %B 588; CHECK: ret i1 true 589} 590 591define i1 @or1(i32 %X) { 592; CHECK-LABEL: @or1( 593 %A = or i32 %X, 62 594 %B = icmp ult i32 %A, 50 595 ret i1 %B 596; CHECK: ret i1 false 597} 598 599define i1 @and1(i32 %X) { 600; CHECK-LABEL: @and1( 601 %A = and i32 %X, 62 602 %B = icmp ugt i32 %A, 70 603 ret i1 %B 604; CHECK: ret i1 false 605} 606 607define i1 @mul1(i32 %X) { 608; CHECK-LABEL: @mul1( 609; Square of a non-zero number is non-zero if there is no overflow. 610 %Y = or i32 %X, 1 611 %M = mul nuw i32 %Y, %Y 612 %C = icmp eq i32 %M, 0 613 ret i1 %C 614; CHECK: ret i1 false 615} 616 617define i1 @mul2(i32 %X) { 618; CHECK-LABEL: @mul2( 619; Square of a non-zero number is positive if there is no signed overflow. 620 %Y = or i32 %X, 1 621 %M = mul nsw i32 %Y, %Y 622 %C = icmp sgt i32 %M, 0 623 ret i1 %C 624; CHECK: ret i1 true 625} 626 627define i1 @mul3(i32 %X, i32 %Y) { 628; CHECK-LABEL: @mul3( 629; Product of non-negative numbers is non-negative if there is no signed overflow. 630 %XX = mul nsw i32 %X, %X 631 %YY = mul nsw i32 %Y, %Y 632 %M = mul nsw i32 %XX, %YY 633 %C = icmp sge i32 %M, 0 634 ret i1 %C 635; CHECK: ret i1 true 636} 637 638define <2 x i1> @vectorselect1(<2 x i1> %cond) { 639; CHECK-LABEL: @vectorselect1( 640 %invert = xor <2 x i1> %cond, <i1 1, i1 1> 641 %s = select <2 x i1> %invert, <2 x i32> <i32 0, i32 0>, <2 x i32> <i32 1, i32 1> 642 %c = icmp ne <2 x i32> %s, <i32 0, i32 0> 643 ret <2 x i1> %c 644; CHECK: ret <2 x i1> %cond 645} 646 647; PR11948 648define <2 x i1> @vectorselectcrash(i32 %arg1) { 649 %tobool40 = icmp ne i32 %arg1, 0 650 %cond43 = select i1 %tobool40, <2 x i16> <i16 -5, i16 66>, <2 x i16> <i16 46, i16 1> 651 %cmp45 = icmp ugt <2 x i16> %cond43, <i16 73, i16 21> 652 ret <2 x i1> %cmp45 653} 654 655; PR12013 656define i1 @alloca_compare(i64 %idx) { 657 %sv = alloca { i32, i32, [124 x i32] } 658 %1 = getelementptr inbounds { i32, i32, [124 x i32] }* %sv, i32 0, i32 2, i64 %idx 659 %2 = icmp eq i32* %1, null 660 ret i1 %2 661 ; CHECK: alloca_compare 662 ; CHECK: ret i1 false 663} 664 665; PR12075 666define i1 @infinite_gep() { 667 ret i1 1 668 669unreachableblock: 670 %X = getelementptr i32 *%X, i32 1 671 %Y = icmp eq i32* %X, null 672 ret i1 %Y 673} 674 675; It's not valid to fold a comparison of an argument with an alloca, even though 676; that's tempting. An argument can't *alias* an alloca, however the aliasing rule 677; relies on restrictions against guessing an object's address and dereferencing. 678; There are no restrictions against guessing an object's address and comparing. 679 680define i1 @alloca_argument_compare(i64* %arg) { 681 %alloc = alloca i64 682 %cmp = icmp eq i64* %arg, %alloc 683 ret i1 %cmp 684 ; CHECK: alloca_argument_compare 685 ; CHECK: ret i1 %cmp 686} 687 688; As above, but with the operands reversed. 689 690define i1 @alloca_argument_compare_swapped(i64* %arg) { 691 %alloc = alloca i64 692 %cmp = icmp eq i64* %alloc, %arg 693 ret i1 %cmp 694 ; CHECK: alloca_argument_compare_swapped 695 ; CHECK: ret i1 %cmp 696} 697 698; Don't assume that a noalias argument isn't equal to a global variable's 699; address. This is an example where AliasAnalysis' NoAlias concept is 700; different from actual pointer inequality. 701 702@y = external global i32 703define zeroext i1 @external_compare(i32* noalias %x) { 704 %cmp = icmp eq i32* %x, @y 705 ret i1 %cmp 706 ; CHECK: external_compare 707 ; CHECK: ret i1 %cmp 708} 709 710define i1 @alloca_gep(i64 %a, i64 %b) { 711; CHECK-LABEL: @alloca_gep( 712; We can prove this GEP is non-null because it is inbounds and the pointer 713; is non-null. 714 %strs = alloca [1000 x [1001 x i8]], align 16 715 %x = getelementptr inbounds [1000 x [1001 x i8]]* %strs, i64 0, i64 %a, i64 %b 716 %cmp = icmp eq i8* %x, null 717 ret i1 %cmp 718; CHECK-NEXT: ret i1 false 719} 720