1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instsimplify -S | FileCheck %s 3target datalayout = "p:32:32-p1:64:64" 4 5define i1 @ptrtoint() { 6; CHECK-LABEL: @ptrtoint( 7; CHECK-NEXT: ret i1 false 8; 9 %a = alloca i8 10 %tmp = ptrtoint i8* %a to i32 11 %r = icmp eq i32 %tmp, 0 12 ret i1 %r 13} 14 15define i1 @bitcast() { 16; CHECK-LABEL: @bitcast( 17; CHECK-NEXT: ret i1 false 18; 19 %a = alloca i32 20 %b = alloca i64 21 %x = bitcast i32* %a to i8* 22 %y = bitcast i64* %b to i8* 23 %cmp = icmp eq i8* %x, %y 24 ret i1 %cmp 25} 26 27define i1 @gep() { 28; CHECK-LABEL: @gep( 29; CHECK-NEXT: ret i1 false 30; 31 %a = alloca [3 x i8], align 8 32 %x = getelementptr inbounds [3 x i8], [3 x i8]* %a, i32 0, i32 0 33 %cmp = icmp eq i8* %x, null 34 ret i1 %cmp 35} 36 37define i1 @gep2() { 38; CHECK-LABEL: @gep2( 39; CHECK-NEXT: ret i1 true 40; 41 %a = alloca [3 x i8], align 8 42 %x = getelementptr inbounds [3 x i8], [3 x i8]* %a, i32 0, i32 0 43 %y = getelementptr inbounds [3 x i8], [3 x i8]* %a, i32 0, i32 0 44 %cmp = icmp eq i8* %x, %y 45 ret i1 %cmp 46} 47 48; PR11238 49%gept = type { i32, i32 } 50@gepy = global %gept zeroinitializer, align 8 51@gepz = extern_weak global %gept 52 53define i1 @gep3() { 54; CHECK-LABEL: @gep3( 55; CHECK-NEXT: ret i1 false 56; 57 %x = alloca %gept, align 8 58 %a = getelementptr %gept, %gept* %x, i64 0, i32 0 59 %b = getelementptr %gept, %gept* %x, i64 0, i32 1 60 %equal = icmp eq i32* %a, %b 61 ret i1 %equal 62} 63 64define i1 @gep4() { 65; CHECK-LABEL: @gep4( 66; CHECK-NEXT: ret i1 false 67; 68 %x = alloca %gept, align 8 69 %a = getelementptr %gept, %gept* @gepy, i64 0, i32 0 70 %b = getelementptr %gept, %gept* @gepy, i64 0, i32 1 71 %equal = icmp eq i32* %a, %b 72 ret i1 %equal 73} 74 75@a = common global [1 x i32] zeroinitializer, align 4 76 77define i1 @PR31262() { 78; CHECK-LABEL: @PR31262( 79; CHECK-NEXT: ret i1 icmp uge (i32* getelementptr ([1 x i32], [1 x i32]* @a, i32 0, i32 undef), i32* getelementptr inbounds ([1 x i32], [1 x i32]* @a, i32 0, i32 0)) 80; 81 %idx = getelementptr inbounds [1 x i32], [1 x i32]* @a, i64 0, i64 undef 82 %cmp = icmp uge i32* %idx, getelementptr inbounds ([1 x i32], [1 x i32]* @a, i32 0, i32 0) 83 ret i1 %cmp 84} 85 86define i1 @gep5() { 87; CHECK-LABEL: @gep5( 88; CHECK-NEXT: ret i1 false 89; 90 %x = alloca %gept, align 8 91 %a = getelementptr inbounds %gept, %gept* %x, i64 0, i32 1 92 %b = getelementptr %gept, %gept* @gepy, i64 0, i32 0 93 %equal = icmp eq i32* %a, %b 94 ret i1 %equal 95} 96 97define i1 @gep6(%gept* %x) { 98; Same as @gep3 but potentially null. 99; CHECK-LABEL: @gep6( 100; CHECK-NEXT: ret i1 false 101; 102 %a = getelementptr %gept, %gept* %x, i64 0, i32 0 103 %b = getelementptr %gept, %gept* %x, i64 0, i32 1 104 %equal = icmp eq i32* %a, %b 105 ret i1 %equal 106} 107 108define i1 @gep7(%gept* %x) { 109; CHECK-LABEL: @gep7( 110; CHECK-NEXT: [[A:%.*]] = getelementptr [[GEPT:%.*]], %gept* [[X:%.*]], i64 0, i32 0 111; CHECK-NEXT: [[EQUAL:%.*]] = icmp eq i32* [[A]], getelementptr (%gept, %gept* @gepz, i32 0, i32 0) 112; CHECK-NEXT: ret i1 [[EQUAL]] 113; 114 %a = getelementptr %gept, %gept* %x, i64 0, i32 0 115 %b = getelementptr %gept, %gept* @gepz, i64 0, i32 0 116 %equal = icmp eq i32* %a, %b 117 ret i1 %equal 118} 119 120define i1 @gep8(%gept* %x) { 121; CHECK-LABEL: @gep8( 122; CHECK-NEXT: [[A:%.*]] = getelementptr [[GEPT:%.*]], %gept* [[X:%.*]], i32 1 123; CHECK-NEXT: [[B:%.*]] = getelementptr [[GEPT]], %gept* [[X]], i32 -1 124; CHECK-NEXT: [[EQUAL:%.*]] = icmp ugt %gept* [[A]], [[B]] 125; CHECK-NEXT: ret i1 [[EQUAL]] 126; 127 %a = getelementptr %gept, %gept* %x, i32 1 128 %b = getelementptr %gept, %gept* %x, i32 -1 129 %equal = icmp ugt %gept* %a, %b 130 ret i1 %equal 131} 132 133define i1 @gep9(i8* %ptr) { 134; CHECK-LABEL: @gep9( 135; CHECK-NEXT: entry: 136; CHECK-NEXT: ret i1 true 137; 138entry: 139 %first1 = getelementptr inbounds i8, i8* %ptr, i32 0 140 %first2 = getelementptr inbounds i8, i8* %first1, i32 1 141 %first3 = getelementptr inbounds i8, i8* %first2, i32 2 142 %first4 = getelementptr inbounds i8, i8* %first3, i32 4 143 %last1 = getelementptr inbounds i8, i8* %first2, i32 48 144 %last2 = getelementptr inbounds i8, i8* %last1, i32 8 145 %last3 = getelementptr inbounds i8, i8* %last2, i32 -4 146 %last4 = getelementptr inbounds i8, i8* %last3, i32 -4 147 %first.int = ptrtoint i8* %first4 to i32 148 %last.int = ptrtoint i8* %last4 to i32 149 %cmp = icmp ne i32 %last.int, %first.int 150 ret i1 %cmp 151} 152 153define i1 @gep10(i8* %ptr) { 154; CHECK-LABEL: @gep10( 155; CHECK-NEXT: entry: 156; CHECK-NEXT: ret i1 true 157; 158entry: 159 %first1 = getelementptr inbounds i8, i8* %ptr, i32 -2 160 %first2 = getelementptr inbounds i8, i8* %first1, i32 44 161 %last1 = getelementptr inbounds i8, i8* %ptr, i32 48 162 %last2 = getelementptr inbounds i8, i8* %last1, i32 -6 163 %first.int = ptrtoint i8* %first2 to i32 164 %last.int = ptrtoint i8* %last2 to i32 165 %cmp = icmp eq i32 %last.int, %first.int 166 ret i1 %cmp 167} 168 169define i1 @gep11(i8* %ptr) { 170; CHECK-LABEL: @gep11( 171; CHECK-NEXT: entry: 172; CHECK-NEXT: ret i1 true 173; 174entry: 175 %first1 = getelementptr inbounds i8, i8* %ptr, i32 -2 176 %last1 = getelementptr inbounds i8, i8* %ptr, i32 48 177 %last2 = getelementptr inbounds i8, i8* %last1, i32 -6 178 %cmp = icmp ult i8* %first1, %last2 179 ret i1 %cmp 180} 181 182define i1 @gep12(i8* %ptr) { 183; CHECK-LABEL: @gep12( 184; CHECK-NEXT: entry: 185; CHECK-NEXT: [[FIRST1:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i32 -2 186; CHECK-NEXT: [[LAST1:%.*]] = getelementptr inbounds i8, i8* [[PTR]], i32 48 187; CHECK-NEXT: [[LAST2:%.*]] = getelementptr inbounds i8, i8* [[LAST1]], i32 -6 188; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8* [[FIRST1]], [[LAST2]] 189; CHECK-NEXT: ret i1 [[CMP]] 190; 191entry: 192 %first1 = getelementptr inbounds i8, i8* %ptr, i32 -2 193 %last1 = getelementptr inbounds i8, i8* %ptr, i32 48 194 %last2 = getelementptr inbounds i8, i8* %last1, i32 -6 195 %cmp = icmp slt i8* %first1, %last2 196 ret i1 %cmp 197} 198 199define i1 @gep13(i8* %ptr) { 200; CHECK-LABEL: @gep13( 201; CHECK-NEXT: ret i1 false 202; 203; We can prove this GEP is non-null because it is inbounds. 204 %x = getelementptr inbounds i8, i8* %ptr, i32 1 205 %cmp = icmp eq i8* %x, null 206 ret i1 %cmp 207} 208 209define i1 @gep13_no_null_opt(i8* %ptr) #0 { 210; We can't prove this GEP is non-null. 211; CHECK-LABEL: @gep13_no_null_opt( 212; CHECK-NEXT: [[X:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i32 1 213; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[X]], null 214; CHECK-NEXT: ret i1 [[CMP]] 215; 216 %x = getelementptr inbounds i8, i8* %ptr, i32 1 217 %cmp = icmp eq i8* %x, null 218 ret i1 %cmp 219} 220 221define i1 @gep14({ {}, i8 }* %ptr) { 222; CHECK-LABEL: @gep14( 223; CHECK-NEXT: [[X:%.*]] = getelementptr inbounds { {}, i8 }, { {}, i8 }* [[PTR:%.*]], i32 0, i32 1 224; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[X]], null 225; CHECK-NEXT: ret i1 [[CMP]] 226; 227; We can't simplify this because the offset of one in the GEP actually doesn't 228; move the pointer. 229 %x = getelementptr inbounds { {}, i8 }, { {}, i8 }* %ptr, i32 0, i32 1 230 %cmp = icmp eq i8* %x, null 231 ret i1 %cmp 232} 233 234define i1 @gep15({ {}, [4 x {i8, i8}]}* %ptr, i32 %y) { 235; CHECK-LABEL: @gep15( 236; CHECK-NEXT: ret i1 false 237; 238; We can prove this GEP is non-null even though there is a user value, as we 239; would necessarily violate inbounds on one side or the other. 240 %x = getelementptr inbounds { {}, [4 x {i8, i8}]}, { {}, [4 x {i8, i8}]}* %ptr, i32 0, i32 1, i32 %y, i32 1 241 %cmp = icmp eq i8* %x, null 242 ret i1 %cmp 243} 244 245define i1 @gep15_no_null_opt({ {}, [4 x {i8, i8}]}* %ptr, i32 %y) #0 { 246; We can't prove this GEP is non-null. 247; CHECK-LABEL: @gep15_no_null_opt( 248; CHECK-NEXT: [[X:%.*]] = getelementptr inbounds { {}, [4 x { i8, i8 }] }, { {}, [4 x { i8, i8 }] }* [[PTR:%.*]], i32 0, i32 1, i32 [[Y:%.*]], i32 1 249; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[X]], null 250; CHECK-NEXT: ret i1 [[CMP]] 251; 252 %x = getelementptr inbounds { {}, [4 x {i8, i8}]}, { {}, [4 x {i8, i8}]}* %ptr, i32 0, i32 1, i32 %y, i32 1 253 %cmp = icmp eq i8* %x, null 254 ret i1 %cmp 255} 256 257define i1 @gep16(i8* %ptr, i32 %a) { 258; CHECK-LABEL: @gep16( 259; CHECK-NEXT: ret i1 false 260; 261; We can prove this GEP is non-null because it is inbounds and because we know 262; %b is non-zero even though we don't know its value. 263 %b = or i32 %a, 1 264 %x = getelementptr inbounds i8, i8* %ptr, i32 %b 265 %cmp = icmp eq i8* %x, null 266 ret i1 %cmp 267} 268 269define i1 @gep16_no_null_opt(i8* %ptr, i32 %a) #0 { 270; We can't prove this GEP is non-null. 271; CHECK-LABEL: @gep16_no_null_opt( 272; CHECK-NEXT: [[B:%.*]] = or i32 [[A:%.*]], 1 273; CHECK-NEXT: [[X:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i32 [[B]] 274; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[X]], null 275; CHECK-NEXT: ret i1 [[CMP]] 276; 277 %b = or i32 %a, 1 278 %x = getelementptr inbounds i8, i8* %ptr, i32 %b 279 %cmp = icmp eq i8* %x, null 280 ret i1 %cmp 281} 282 283define i1 @gep17() { 284; CHECK-LABEL: @gep17( 285; CHECK-NEXT: ret i1 true 286; 287 %alloca = alloca i32, align 4 288 %bc = bitcast i32* %alloca to [4 x i8]* 289 %gep1 = getelementptr inbounds i32, i32* %alloca, i32 1 290 %pti1 = ptrtoint i32* %gep1 to i32 291 %gep2 = getelementptr inbounds [4 x i8], [4 x i8]* %bc, i32 0, i32 1 292 %pti2 = ptrtoint i8* %gep2 to i32 293 %cmp = icmp ugt i32 %pti1, %pti2 294 ret i1 %cmp 295} 296 297define i1 @gep_same_base_constant_indices(i8* %a) { 298; CHECK-LABEL: @gep_same_base_constant_indices( 299; CHECK-NEXT: ret i1 true 300; 301 %arrayidx1 = getelementptr inbounds i8, i8* %a, i64 1 302 %arrayidx2 = getelementptr inbounds i8, i8* %a, i64 10 303 %cmp = icmp slt i8* %arrayidx1, %arrayidx2 304 ret i1 %cmp 305} 306 307define i1 @zext(i32 %x) { 308; CHECK-LABEL: @zext( 309; CHECK-NEXT: ret i1 true 310; 311 %e1 = zext i32 %x to i64 312 %e2 = zext i32 %x to i64 313 %r = icmp eq i64 %e1, %e2 314 ret i1 %r 315} 316 317define i1 @zext2(i1 %x) { 318; CHECK-LABEL: @zext2( 319; CHECK-NEXT: ret i1 [[X:%.*]] 320; 321 %e = zext i1 %x to i32 322 %c = icmp ne i32 %e, 0 323 ret i1 %c 324} 325 326define i1 @zext3() { 327; CHECK-LABEL: @zext3( 328; CHECK-NEXT: ret i1 true 329; 330 %e = zext i1 1 to i32 331 %c = icmp ne i32 %e, 0 332 ret i1 %c 333} 334 335define i1 @sext(i32 %x) { 336; CHECK-LABEL: @sext( 337; CHECK-NEXT: ret i1 true 338; 339 %e1 = sext i32 %x to i64 340 %e2 = sext i32 %x to i64 341 %r = icmp eq i64 %e1, %e2 342 ret i1 %r 343} 344 345define i1 @sext2(i1 %x) { 346; CHECK-LABEL: @sext2( 347; CHECK-NEXT: ret i1 [[X:%.*]] 348; 349 %e = sext i1 %x to i32 350 %c = icmp ne i32 %e, 0 351 ret i1 %c 352} 353 354define i1 @sext3() { 355; CHECK-LABEL: @sext3( 356; CHECK-NEXT: ret i1 true 357; 358 %e = sext i1 1 to i32 359 %c = icmp ne i32 %e, 0 360 ret i1 %c 361} 362 363define i1 @add(i32 %x, i32 %y) { 364; CHECK-LABEL: @add( 365; CHECK-NEXT: ret i1 false 366; 367 %l = lshr i32 %x, 1 368 %q = lshr i32 %y, 1 369 %r = or i32 %q, 1 370 %s = add i32 %l, %r 371 %c = icmp eq i32 %s, 0 372 ret i1 %c 373} 374 375define i1 @addv(<2 x i32> %x, <2 x i32> %y) { 376; CHECK-LABEL: @addv( 377; CHECK-NEXT: ret i1 false 378; 379 %l = lshr <2 x i32> %x, <i32 1, i32 0> 380 %q = lshr <2 x i32> %y, <i32 1, i32 0> 381 %r = or <2 x i32> %q, <i32 1, i32 0> 382 %s = add <2 x i32> %l, %r 383 %e = extractelement <2 x i32> %s, i32 0 384 %c = icmp eq i32 %e, 0 385 ret i1 %c 386} 387 388define i1 @add2(i8 %x, i8 %y) { 389; CHECK-LABEL: @add2( 390; CHECK-NEXT: ret i1 false 391; 392 %l = or i8 %x, 128 393 %r = or i8 %y, 129 394 %s = add i8 %l, %r 395 %c = icmp eq i8 %s, 0 396 ret i1 %c 397} 398 399define i1 @add2v(<2 x i8> %x, <2 x i8> %y) { 400; CHECK-LABEL: @add2v( 401; CHECK-NEXT: ret i1 false 402; 403 %l = or <2 x i8> %x, <i8 0, i8 128> 404 %r = or <2 x i8> %y, <i8 0, i8 129> 405 %s = add <2 x i8> %l, %r 406 %e = extractelement <2 x i8> %s, i32 1 407 %c = icmp eq i8 %e, 0 408 ret i1 %c 409} 410 411define i1 @add3(i8 %x, i8 %y) { 412; CHECK-LABEL: @add3( 413; CHECK-NEXT: [[L:%.*]] = zext i8 [[X:%.*]] to i32 414; CHECK-NEXT: [[R:%.*]] = zext i8 [[Y:%.*]] to i32 415; CHECK-NEXT: [[S:%.*]] = add i32 [[L]], [[R]] 416; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[S]], 0 417; CHECK-NEXT: ret i1 [[C]] 418; 419 %l = zext i8 %x to i32 420 %r = zext i8 %y to i32 421 %s = add i32 %l, %r 422 %c = icmp eq i32 %s, 0 423 ret i1 %c 424} 425 426define i1 @add4(i32 %x, i32 %y) { 427; CHECK-LABEL: @add4( 428; CHECK-NEXT: ret i1 true 429; 430 %z = add nsw i32 %y, 1 431 %s1 = add nsw i32 %x, %y 432 %s2 = add nsw i32 %x, %z 433 %c = icmp slt i32 %s1, %s2 434 ret i1 %c 435} 436 437define i1 @add5(i32 %x, i32 %y) { 438; CHECK-LABEL: @add5( 439; CHECK-NEXT: ret i1 true 440; 441 %z = add nuw i32 %y, 1 442 %s1 = add nuw i32 %x, %z 443 %s2 = add nuw i32 %x, %y 444 %c = icmp ugt i32 %s1, %s2 445 ret i1 %c 446} 447 448define i1 @add6(i64 %A, i64 %B) { 449; CHECK-LABEL: @add6( 450; CHECK-NEXT: ret i1 true 451; 452 %s1 = add i64 %A, %B 453 %s2 = add i64 %B, %A 454 %cmp = icmp eq i64 %s1, %s2 455 ret i1 %cmp 456} 457 458define i1 @addpowtwo(i32 %x, i32 %y) { 459; CHECK-LABEL: @addpowtwo( 460; CHECK-NEXT: ret i1 false 461; 462 %l = lshr i32 %x, 1 463 %r = shl i32 1, %y 464 %s = add i32 %l, %r 465 %c = icmp eq i32 %s, 0 466 ret i1 %c 467} 468 469define i1 @addpowtwov(<2 x i32> %x, <2 x i32> %y) { 470; CHECK-LABEL: @addpowtwov( 471; CHECK-NEXT: [[L:%.*]] = lshr <2 x i32> [[X:%.*]], <i32 1, i32 0> 472; CHECK-NEXT: [[R:%.*]] = shl <2 x i32> <i32 1, i32 0>, [[Y:%.*]] 473; CHECK-NEXT: [[S:%.*]] = add <2 x i32> [[L]], [[R]] 474; CHECK-NEXT: [[E:%.*]] = extractelement <2 x i32> [[S]], i32 0 475; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[E]], 0 476; CHECK-NEXT: ret i1 [[C]] 477; 478 %l = lshr <2 x i32> %x, <i32 1, i32 0> 479 %r = shl <2 x i32> <i32 1, i32 0>, %y 480 %s = add <2 x i32> %l, %r 481 %e = extractelement <2 x i32> %s, i32 0 482 %c = icmp eq i32 %e, 0 483 ret i1 %c 484} 485 486define i1 @or(i32 %x) { 487; CHECK-LABEL: @or( 488; CHECK-NEXT: ret i1 false 489; 490 %o = or i32 %x, 1 491 %c = icmp eq i32 %o, 0 492 ret i1 %c 493} 494 495; Do not simplify if we cannot guarantee that the ConstantExpr is a non-zero 496; constant. 497@GV = common global i32* null 498define i1 @or_constexp(i32 %x) { 499; CHECK-LABEL: @or_constexp( 500; CHECK-NEXT: entry: 501; CHECK-NEXT: [[O:%.*]] = or i32 [[X:%.*]], and (i32 ptrtoint (i32** @GV to i32), i32 32) 502; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[O]], 0 503; CHECK-NEXT: ret i1 [[C]] 504; 505entry: 506 %0 = and i32 ptrtoint (i32** @GV to i32), 32 507 %o = or i32 %x, %0 508 %c = icmp eq i32 %o, 0 509 ret i1 %c 510} 511 512define i1 @shl1(i32 %x) { 513; CHECK-LABEL: @shl1( 514; CHECK-NEXT: ret i1 false 515; 516 %s = shl i32 1, %x 517 %c = icmp eq i32 %s, 0 518 ret i1 %c 519} 520 521define i1 @shl3(i32 %X) { 522; CHECK-LABEL: @shl3( 523; CHECK-NEXT: ret i1 false 524; 525 %sub = shl nuw i32 4, %X 526 %cmp = icmp eq i32 %sub, 31 527 ret i1 %cmp 528} 529 530define i1 @lshr1(i32 %x) { 531; CHECK-LABEL: @lshr1( 532; CHECK-NEXT: ret i1 false 533; 534 %s = lshr i32 -1, %x 535 %c = icmp eq i32 %s, 0 536 ret i1 %c 537} 538 539define i1 @lshr3(i32 %x) { 540; CHECK-LABEL: @lshr3( 541; CHECK-NEXT: ret i1 true 542; 543 %s = lshr i32 %x, %x 544 %c = icmp eq i32 %s, 0 545 ret i1 %c 546} 547 548define i1 @lshr4(i32 %X, i32 %Y) { 549; CHECK-LABEL: @lshr4( 550; CHECK-NEXT: ret i1 true 551; 552 %A = lshr i32 %X, %Y 553 %C = icmp ule i32 %A, %X 554 ret i1 %C 555} 556 557define i1 @lshr5(i32 %X, i32 %Y) { 558; CHECK-LABEL: @lshr5( 559; CHECK-NEXT: ret i1 false 560; 561 %A = lshr i32 %X, %Y 562 %C = icmp ugt i32 %A, %X 563 ret i1 %C 564} 565 566define i1 @lshr6(i32 %X, i32 %Y) { 567; CHECK-LABEL: @lshr6( 568; CHECK-NEXT: ret i1 false 569; 570 %A = lshr i32 %X, %Y 571 %C = icmp ult i32 %X, %A 572 ret i1 %C 573} 574 575define i1 @lshr7(i32 %X, i32 %Y) { 576; CHECK-LABEL: @lshr7( 577; CHECK-NEXT: ret i1 true 578; 579 %A = lshr i32 %X, %Y 580 %C = icmp uge i32 %X, %A 581 ret i1 %C 582} 583 584define i1 @ashr1(i32 %x) { 585; CHECK-LABEL: @ashr1( 586; CHECK-NEXT: ret i1 false 587; 588 %s = ashr i32 -1, %x 589 %c = icmp eq i32 %s, 0 590 ret i1 %c 591} 592 593define i1 @ashr3(i32 %x) { 594; CHECK-LABEL: @ashr3( 595; CHECK-NEXT: ret i1 true 596; 597 %s = ashr i32 %x, %x 598 %c = icmp eq i32 %s, 0 599 ret i1 %c 600} 601 602define i1 @select1(i1 %cond) { 603; CHECK-LABEL: @select1( 604; CHECK-NEXT: ret i1 [[COND:%.*]] 605; 606 %s = select i1 %cond, i32 1, i32 0 607 %c = icmp eq i32 %s, 1 608 ret i1 %c 609} 610 611define i1 @select2(i1 %cond) { 612; CHECK-LABEL: @select2( 613; CHECK-NEXT: ret i1 [[COND:%.*]] 614; 615 %x = zext i1 %cond to i32 616 %s = select i1 %cond, i32 %x, i32 0 617 %c = icmp ne i32 %s, 0 618 ret i1 %c 619} 620 621define i1 @select3(i1 %cond) { 622; CHECK-LABEL: @select3( 623; CHECK-NEXT: ret i1 [[COND:%.*]] 624; 625 %x = zext i1 %cond to i32 626 %s = select i1 %cond, i32 1, i32 %x 627 %c = icmp ne i32 %s, 0 628 ret i1 %c 629} 630 631define i1 @select4(i1 %cond) { 632; CHECK-LABEL: @select4( 633; CHECK-NEXT: ret i1 [[COND:%.*]] 634; 635 %invert = xor i1 %cond, 1 636 %s = select i1 %invert, i32 0, i32 1 637 %c = icmp ne i32 %s, 0 638 ret i1 %c 639} 640 641define i1 @select5(i32 %x) { 642; CHECK-LABEL: @select5( 643; CHECK-NEXT: ret i1 false 644; 645 %c = icmp eq i32 %x, 0 646 %s = select i1 %c, i32 1, i32 %x 647 %c2 = icmp eq i32 %s, 0 648 ret i1 %c2 649} 650 651define i1 @select6(i32 %x) { 652; CHECK-LABEL: @select6( 653; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[X:%.*]], 0 654; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i32 [[X]], i32 4 655; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[S]], 0 656; CHECK-NEXT: ret i1 [[C2]] 657; 658 %c = icmp sgt i32 %x, 0 659 %s = select i1 %c, i32 %x, i32 4 660 %c2 = icmp eq i32 %s, 0 661 ret i1 %c2 662} 663 664define i1 @urem1(i32 %X, i32 %Y) { 665; CHECK-LABEL: @urem1( 666; CHECK-NEXT: ret i1 true 667; 668 %A = urem i32 %X, %Y 669 %B = icmp ult i32 %A, %Y 670 ret i1 %B 671} 672 673define i1 @urem2(i32 %X, i32 %Y) { 674; CHECK-LABEL: @urem2( 675; CHECK-NEXT: ret i1 false 676; 677 %A = urem i32 %X, %Y 678 %B = icmp eq i32 %A, %Y 679 ret i1 %B 680} 681 682define i1 @urem4(i32 %X) { 683; CHECK-LABEL: @urem4( 684; CHECK-NEXT: [[A:%.*]] = urem i32 [[X:%.*]], 15 685; CHECK-NEXT: [[B:%.*]] = icmp ult i32 [[A]], 10 686; CHECK-NEXT: ret i1 [[B]] 687; 688 %A = urem i32 %X, 15 689 %B = icmp ult i32 %A, 10 690 ret i1 %B 691} 692 693define i1 @urem5(i16 %X, i32 %Y) { 694; CHECK-LABEL: @urem5( 695; CHECK-NEXT: [[A:%.*]] = zext i16 [[X:%.*]] to i32 696; CHECK-NEXT: [[B:%.*]] = urem i32 [[A]], [[Y:%.*]] 697; CHECK-NEXT: [[C:%.*]] = icmp slt i32 [[B]], [[Y]] 698; CHECK-NEXT: ret i1 [[C]] 699; 700 %A = zext i16 %X to i32 701 %B = urem i32 %A, %Y 702 %C = icmp slt i32 %B, %Y 703 ret i1 %C 704} 705 706define i1 @urem6(i32 %X, i32 %Y) { 707; CHECK-LABEL: @urem6( 708; CHECK-NEXT: ret i1 true 709; 710 %A = urem i32 %X, %Y 711 %B = icmp ugt i32 %Y, %A 712 ret i1 %B 713} 714 715define i1 @urem7(i32 %X) { 716; CHECK-LABEL: @urem7( 717; CHECK-NEXT: [[A:%.*]] = urem i32 1, [[X:%.*]] 718; CHECK-NEXT: [[B:%.*]] = icmp sgt i32 [[A]], [[X]] 719; CHECK-NEXT: ret i1 [[B]] 720; 721 %A = urem i32 1, %X 722 %B = icmp sgt i32 %A, %X 723 ret i1 %B 724} 725 726; PR9343 #15 727define i1 @srem2(i16 %X, i32 %Y) { 728; CHECK-LABEL: @srem2( 729; CHECK-NEXT: ret i1 false 730; 731 %A = zext i16 %X to i32 732 %B = add nsw i32 %A, 1 733 %C = srem i32 %B, %Y 734 %D = icmp slt i32 %C, 0 735 ret i1 %D 736} 737 738define i1 @srem2v(<2 x i16> %X, <2 x i32> %Y) { 739; CHECK-LABEL: @srem2v( 740; CHECK-NEXT: ret i1 false 741; 742 %A = zext <2 x i16> %X to <2 x i32> 743 %B = add nsw <2 x i32> %A, <i32 1, i32 0> 744 %C = srem <2 x i32> %B, %Y 745 %D = extractelement <2 x i32> %C, i32 0 746 %E = icmp slt i32 %D, 0 747 ret i1 %E 748} 749 750define i1 @srem3(i16 %X, i32 %Y) { 751; CHECK-LABEL: @srem3( 752; CHECK-NEXT: ret i1 false 753; 754 %A = zext i16 %X to i32 755 %B = or i32 2147483648, %A 756 %C = sub nsw i32 1, %B 757 %D = srem i32 %C, %Y 758 %E = icmp slt i32 %D, 0 759 ret i1 %E 760} 761 762define i1 @srem3v(<2 x i16> %X, <2 x i32> %Y) { 763; CHECK-LABEL: @srem3v( 764; CHECK-NEXT: ret i1 false 765; 766 %A = zext <2 x i16> %X to <2 x i32> 767 %B = or <2 x i32> <i32 1, i32 2147483648>, %A 768 %C = sub nsw <2 x i32> <i32 0, i32 1>, %B 769 %D = srem <2 x i32> %C, %Y 770 %E = extractelement <2 x i32> %C, i32 1 771 %F = icmp slt i32 %E, 0 772 ret i1 %F 773} 774 775define i1 @udiv2(i32 %Z) { 776; CHECK-LABEL: @udiv2( 777; CHECK-NEXT: ret i1 true 778; 779 %A = udiv exact i32 10, %Z 780 %B = udiv exact i32 20, %Z 781 %C = icmp ult i32 %A, %B 782 ret i1 %C 783} 784 785; Exact sdiv and equality preds can simplify. 786 787define i1 @sdiv_exact_equality(i32 %Z) { 788; CHECK-LABEL: @sdiv_exact_equality( 789; CHECK-NEXT: ret i1 false 790; 791 %A = sdiv exact i32 10, %Z 792 %B = sdiv exact i32 20, %Z 793 %C = icmp eq i32 %A, %B 794 ret i1 %C 795} 796 797; But not other preds: PR32949 - https://bugs.llvm.org/show_bug.cgi?id=32949 798 799define i1 @sdiv_exact_not_equality(i32 %Z) { 800; CHECK-LABEL: @sdiv_exact_not_equality( 801; CHECK-NEXT: [[A:%.*]] = sdiv exact i32 10, [[Z:%.*]] 802; CHECK-NEXT: [[B:%.*]] = sdiv exact i32 20, [[Z]] 803; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A]], [[B]] 804; CHECK-NEXT: ret i1 [[C]] 805; 806 %A = sdiv exact i32 10, %Z 807 %B = sdiv exact i32 20, %Z 808 %C = icmp ult i32 %A, %B 809 ret i1 %C 810} 811 812define i1 @udiv3(i32 %X, i32 %Y) { 813; CHECK-LABEL: @udiv3( 814; CHECK-NEXT: ret i1 false 815; 816 %A = udiv i32 %X, %Y 817 %C = icmp ugt i32 %A, %X 818 ret i1 %C 819} 820 821define i1 @udiv4(i32 %X, i32 %Y) { 822; CHECK-LABEL: @udiv4( 823; CHECK-NEXT: ret i1 true 824; 825 %A = udiv i32 %X, %Y 826 %C = icmp ule i32 %A, %X 827 ret i1 %C 828} 829 830; PR11340 831define i1 @udiv6(i32 %X) nounwind { 832; CHECK-LABEL: @udiv6( 833; CHECK-NEXT: [[A:%.*]] = udiv i32 1, [[X:%.*]] 834; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[A]], 0 835; CHECK-NEXT: ret i1 [[C]] 836; 837 %A = udiv i32 1, %X 838 %C = icmp eq i32 %A, 0 839 ret i1 %C 840} 841 842define i1 @udiv7(i32 %X, i32 %Y) { 843; CHECK-LABEL: @udiv7( 844; CHECK-NEXT: ret i1 false 845; 846 %A = udiv i32 %X, %Y 847 %C = icmp ult i32 %X, %A 848 ret i1 %C 849} 850 851define i1 @udiv8(i32 %X, i32 %Y) { 852; CHECK-LABEL: @udiv8( 853; CHECK-NEXT: ret i1 true 854; 855 %A = udiv i32 %X, %Y 856 %C = icmp uge i32 %X, %A 857 ret i1 %C 858} 859 860; Square of a non-zero number is non-zero if there is no overflow. 861define i1 @mul1(i32 %X) { 862; CHECK-LABEL: @mul1( 863; CHECK-NEXT: ret i1 false 864; 865 %Y = or i32 %X, 1 866 %M = mul nuw i32 %Y, %Y 867 %C = icmp eq i32 %M, 0 868 ret i1 %C 869} 870 871define i1 @mul1v(<2 x i32> %X) { 872; CHECK-LABEL: @mul1v( 873; CHECK-NEXT: ret i1 false 874; 875 %Y = or <2 x i32> %X, <i32 1, i32 0> 876 %M = mul nuw <2 x i32> %Y, %Y 877 %E = extractelement <2 x i32> %M, i32 0 878 %C = icmp eq i32 %E, 0 879 ret i1 %C 880} 881 882; Square of a non-zero number is positive if there is no signed overflow. 883define i1 @mul2(i32 %X) { 884; CHECK-LABEL: @mul2( 885; CHECK-NEXT: ret i1 true 886; 887 %Y = or i32 %X, 1 888 %M = mul nsw i32 %Y, %Y 889 %C = icmp sgt i32 %M, 0 890 ret i1 %C 891} 892 893define i1 @mul2v(<2 x i32> %X) { 894; CHECK-LABEL: @mul2v( 895; CHECK-NEXT: ret i1 true 896; 897 %Y = or <2 x i32> %X, <i32 0, i32 1> 898 %M = mul nsw <2 x i32> %Y, %Y 899 %E = extractelement <2 x i32> %M, i32 1 900 %C = icmp sgt i32 %E, 0 901 ret i1 %C 902} 903 904; Product of non-negative numbers is non-negative if there is no signed overflow. 905define i1 @mul3(i32 %X, i32 %Y) { 906; CHECK-LABEL: @mul3( 907; CHECK-NEXT: ret i1 true 908; 909 %XX = mul nsw i32 %X, %X 910 %YY = mul nsw i32 %Y, %Y 911 %M = mul nsw i32 %XX, %YY 912 %C = icmp sge i32 %M, 0 913 ret i1 %C 914} 915 916define <2 x i1> @mul3v(<2 x i32> %X, <2 x i32> %Y) { 917; CHECK-LABEL: @mul3v( 918; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true> 919; 920 %XX = mul nsw <2 x i32> %X, %X 921 %YY = mul nsw <2 x i32> %Y, %Y 922 %M = mul nsw <2 x i32> %XX, %YY 923 %C = icmp sge <2 x i32> %M, zeroinitializer 924 ret <2 x i1> %C 925} 926 927define <2 x i1> @vectorselect1(<2 x i1> %cond) { 928; CHECK-LABEL: @vectorselect1( 929; CHECK-NEXT: ret <2 x i1> [[COND:%.*]] 930; 931 %invert = xor <2 x i1> %cond, <i1 1, i1 1> 932 %s = select <2 x i1> %invert, <2 x i32> <i32 0, i32 0>, <2 x i32> <i32 1, i32 1> 933 %c = icmp ne <2 x i32> %s, <i32 0, i32 0> 934 ret <2 x i1> %c 935} 936 937; PR11948 938define <2 x i1> @vectorselectcrash(i32 %arg1) { 939; CHECK-LABEL: @vectorselectcrash( 940; CHECK-NEXT: [[TOBOOL40:%.*]] = icmp ne i32 [[ARG1:%.*]], 0 941; CHECK-NEXT: [[COND43:%.*]] = select i1 [[TOBOOL40]], <2 x i16> <i16 -5, i16 66>, <2 x i16> <i16 46, i16 1> 942; CHECK-NEXT: [[CMP45:%.*]] = icmp ugt <2 x i16> [[COND43]], <i16 73, i16 21> 943; CHECK-NEXT: ret <2 x i1> [[CMP45]] 944; 945 %tobool40 = icmp ne i32 %arg1, 0 946 %cond43 = select i1 %tobool40, <2 x i16> <i16 -5, i16 66>, <2 x i16> <i16 46, i16 1> 947 %cmp45 = icmp ugt <2 x i16> %cond43, <i16 73, i16 21> 948 ret <2 x i1> %cmp45 949} 950 951; PR12013 952define i1 @alloca_compare(i64 %idx) { 953; CHECK-LABEL: @alloca_compare( 954; CHECK-NEXT: ret i1 false 955; 956 %sv = alloca { i32, i32, [124 x i32] } 957 %1 = getelementptr inbounds { i32, i32, [124 x i32] }, { i32, i32, [124 x i32] }* %sv, i32 0, i32 2, i64 %idx 958 %2 = icmp eq i32* %1, null 959 ret i1 %2 960} 961 962define i1 @alloca_compare_no_null_opt(i64 %idx) #0 { 963; CHECK-LABEL: @alloca_compare_no_null_opt( 964; CHECK-NEXT: [[SV:%.*]] = alloca { i32, i32, [124 x i32] } 965; CHECK-NEXT: [[CMP:%.*]] = getelementptr inbounds { i32, i32, [124 x i32] }, { i32, i32, [124 x i32] }* [[SV]], i32 0, i32 2, i64 [[IDX:%.*]] 966; CHECK-NEXT: [[X:%.*]] = icmp eq i32* [[CMP]], null 967; CHECK-NEXT: ret i1 [[X]] 968; 969 %sv = alloca { i32, i32, [124 x i32] } 970 %cmp = getelementptr inbounds { i32, i32, [124 x i32] }, { i32, i32, [124 x i32] }* %sv, i32 0, i32 2, i64 %idx 971 %X = icmp eq i32* %cmp, null 972 ret i1 %X 973} 974; PR12075 975define i1 @infinite_gep() { 976; CHECK-LABEL: @infinite_gep( 977; CHECK-NEXT: ret i1 true 978; CHECK: unreachableblock: 979; CHECK-NEXT: [[X:%.*]] = getelementptr i32, i32* [[X]], i32 1 980; CHECK-NEXT: [[Y:%.*]] = icmp eq i32* [[X]], null 981; CHECK-NEXT: ret i1 [[Y]] 982; 983 ret i1 1 984 985unreachableblock: 986 %X = getelementptr i32, i32 *%X, i32 1 987 %Y = icmp eq i32* %X, null 988 ret i1 %Y 989} 990 991; It's not valid to fold a comparison of an argument with an alloca, even though 992; that's tempting. An argument can't *alias* an alloca, however the aliasing rule 993; relies on restrictions against guessing an object's address and dereferencing. 994; There are no restrictions against guessing an object's address and comparing. 995 996define i1 @alloca_argument_compare(i64* %arg) { 997; CHECK-LABEL: @alloca_argument_compare( 998; CHECK-NEXT: [[ALLOC:%.*]] = alloca i64 999; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64* [[ARG:%.*]], [[ALLOC]] 1000; CHECK-NEXT: ret i1 [[CMP]] 1001; 1002 %alloc = alloca i64 1003 %cmp = icmp eq i64* %arg, %alloc 1004 ret i1 %cmp 1005} 1006 1007; As above, but with the operands reversed. 1008 1009define i1 @alloca_argument_compare_swapped(i64* %arg) { 1010; CHECK-LABEL: @alloca_argument_compare_swapped( 1011; CHECK-NEXT: [[ALLOC:%.*]] = alloca i64 1012; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64* [[ALLOC]], [[ARG:%.*]] 1013; CHECK-NEXT: ret i1 [[CMP]] 1014; 1015 %alloc = alloca i64 1016 %cmp = icmp eq i64* %alloc, %arg 1017 ret i1 %cmp 1018} 1019 1020; Don't assume that a noalias argument isn't equal to a global variable's 1021; address. This is an example where AliasAnalysis' NoAlias concept is 1022; different from actual pointer inequality. 1023 1024@y = external global i32 1025define zeroext i1 @external_compare(i32* noalias %x) { 1026; CHECK-LABEL: @external_compare( 1027; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[X:%.*]], @y 1028; CHECK-NEXT: ret i1 [[CMP]] 1029; 1030 %cmp = icmp eq i32* %x, @y 1031 ret i1 %cmp 1032} 1033 1034define i1 @alloca_gep(i64 %a, i64 %b) { 1035; CHECK-LABEL: @alloca_gep( 1036; CHECK-NEXT: ret i1 false 1037; 1038; We can prove this GEP is non-null because it is inbounds and the pointer 1039; is non-null. 1040 %strs = alloca [1000 x [1001 x i8]], align 16 1041 %x = getelementptr inbounds [1000 x [1001 x i8]], [1000 x [1001 x i8]]* %strs, i64 0, i64 %a, i64 %b 1042 %cmp = icmp eq i8* %x, null 1043 ret i1 %cmp 1044} 1045 1046define i1 @alloca_gep_no_null_opt(i64 %a, i64 %b) #0 { 1047; CHECK-LABEL: @alloca_gep_no_null_opt( 1048; CHECK-NEXT: [[STRS:%.*]] = alloca [1000 x [1001 x i8]], align 16 1049; CHECK-NEXT: [[X:%.*]] = getelementptr inbounds [1000 x [1001 x i8]], [1000 x [1001 x i8]]* [[STRS]], i64 0, i64 [[A:%.*]], i64 [[B:%.*]] 1050; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[X]], null 1051; CHECK-NEXT: ret i1 [[CMP]] 1052; 1053; We can't prove this GEP is non-null. 1054 %strs = alloca [1000 x [1001 x i8]], align 16 1055 %x = getelementptr inbounds [1000 x [1001 x i8]], [1000 x [1001 x i8]]* %strs, i64 0, i64 %a, i64 %b 1056 %cmp = icmp eq i8* %x, null 1057 ret i1 %cmp 1058} 1059 1060define i1 @non_inbounds_gep_compare(i64* %a) { 1061; CHECK-LABEL: @non_inbounds_gep_compare( 1062; CHECK-NEXT: ret i1 true 1063; 1064; Equality compares with non-inbounds GEPs can be folded. 1065 %x = getelementptr i64, i64* %a, i64 42 1066 %y = getelementptr inbounds i64, i64* %x, i64 -42 1067 %z = getelementptr i64, i64* %a, i64 -42 1068 %w = getelementptr inbounds i64, i64* %z, i64 42 1069 %cmp = icmp eq i64* %y, %w 1070 ret i1 %cmp 1071} 1072 1073define i1 @non_inbounds_gep_compare2(i64* %a) { 1074; CHECK-LABEL: @non_inbounds_gep_compare2( 1075; CHECK-NEXT: ret i1 true 1076; 1077; Equality compares with non-inbounds GEPs can be folded. 1078 %x = getelementptr i64, i64* %a, i64 4294967297 1079 %y = getelementptr i64, i64* %a, i64 1 1080 %cmp = icmp eq i64* %y, %y 1081 ret i1 %cmp 1082} 1083 1084define i1 @compare_always_true_slt(i16 %a) { 1085; CHECK-LABEL: @compare_always_true_slt( 1086; CHECK-NEXT: ret i1 true 1087; 1088 %1 = zext i16 %a to i32 1089 %2 = sub nsw i32 0, %1 1090 %3 = icmp slt i32 %2, 1 1091 ret i1 %3 1092 1093} 1094 1095define i1 @compare_always_true_sle(i16 %a) { 1096; CHECK-LABEL: @compare_always_true_sle( 1097; CHECK-NEXT: ret i1 true 1098; 1099 %1 = zext i16 %a to i32 1100 %2 = sub nsw i32 0, %1 1101 %3 = icmp sle i32 %2, 0 1102 ret i1 %3 1103 1104} 1105 1106define i1 @compare_always_false_sgt(i16 %a) { 1107; CHECK-LABEL: @compare_always_false_sgt( 1108; CHECK-NEXT: ret i1 false 1109; 1110 %1 = zext i16 %a to i32 1111 %2 = sub nsw i32 0, %1 1112 %3 = icmp sgt i32 %2, 0 1113 ret i1 %3 1114 1115} 1116 1117define i1 @compare_always_false_sge(i16 %a) { 1118; CHECK-LABEL: @compare_always_false_sge( 1119; CHECK-NEXT: ret i1 false 1120; 1121 %1 = zext i16 %a to i32 1122 %2 = sub nsw i32 0, %1 1123 %3 = icmp sge i32 %2, 1 1124 ret i1 %3 1125 1126} 1127 1128define i1 @compare_always_false_eq(i16 %a) { 1129; CHECK-LABEL: @compare_always_false_eq( 1130; CHECK-NEXT: ret i1 false 1131; 1132 %1 = zext i16 %a to i32 1133 %2 = sub nsw i32 0, %1 1134 %3 = icmp eq i32 %2, 1 1135 ret i1 %3 1136 1137} 1138 1139define i1 @compare_always_false_ne(i16 %a) { 1140; CHECK-LABEL: @compare_always_false_ne( 1141; CHECK-NEXT: ret i1 true 1142; 1143 %1 = zext i16 %a to i32 1144 %2 = sub nsw i32 0, %1 1145 %3 = icmp ne i32 %2, 1 1146 ret i1 %3 1147 1148} 1149 1150define i1 @lshr_ugt_false(i32 %a) { 1151; CHECK-LABEL: @lshr_ugt_false( 1152; CHECK-NEXT: ret i1 false 1153; 1154 %shr = lshr i32 1, %a 1155 %cmp = icmp ugt i32 %shr, 1 1156 ret i1 %cmp 1157} 1158 1159define i1 @nonnull_arg(i32* nonnull %i) { 1160; CHECK-LABEL: @nonnull_arg( 1161; CHECK-NEXT: ret i1 false 1162; 1163 %cmp = icmp eq i32* %i, null 1164 ret i1 %cmp 1165} 1166 1167define i1 @nonnull_arg_no_null_opt(i32* nonnull %i) #0 { 1168; CHECK-LABEL: @nonnull_arg_no_null_opt( 1169; CHECK-NEXT: ret i1 false 1170; 1171 %cmp = icmp eq i32* %i, null 1172 ret i1 %cmp 1173} 1174 1175define i1 @nonnull_deref_arg(i32* dereferenceable(4) %i) { 1176; CHECK-LABEL: @nonnull_deref_arg( 1177; CHECK-NEXT: ret i1 false 1178; 1179 %cmp = icmp eq i32* %i, null 1180 ret i1 %cmp 1181} 1182 1183define i1 @nonnull_deref_arg_no_null_opt(i32* dereferenceable(4) %i) #0 { 1184; CHECK-LABEL: @nonnull_deref_arg_no_null_opt( 1185; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[I:%.*]], null 1186; CHECK-NEXT: ret i1 [[CMP]] 1187; 1188 %cmp = icmp eq i32* %i, null 1189 ret i1 %cmp 1190} 1191define i1 @nonnull_deref_as_arg(i32 addrspace(1)* dereferenceable(4) %i) { 1192; CHECK-LABEL: @nonnull_deref_as_arg( 1193; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 addrspace(1)* [[I:%.*]], null 1194; CHECK-NEXT: ret i1 [[CMP]] 1195; 1196 %cmp = icmp eq i32 addrspace(1)* %i, null 1197 ret i1 %cmp 1198} 1199 1200declare nonnull i32* @returns_nonnull_helper() 1201define i1 @returns_nonnull() { 1202; CHECK-LABEL: @returns_nonnull( 1203; CHECK-NEXT: [[CALL:%.*]] = call nonnull i32* @returns_nonnull_helper() 1204; CHECK-NEXT: ret i1 false 1205; 1206 %call = call nonnull i32* @returns_nonnull_helper() 1207 %cmp = icmp eq i32* %call, null 1208 ret i1 %cmp 1209} 1210 1211declare dereferenceable(4) i32* @returns_nonnull_deref_helper() 1212define i1 @returns_nonnull_deref() { 1213; CHECK-LABEL: @returns_nonnull_deref( 1214; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(4) i32* @returns_nonnull_deref_helper() 1215; CHECK-NEXT: ret i1 false 1216; 1217 %call = call dereferenceable(4) i32* @returns_nonnull_deref_helper() 1218 %cmp = icmp eq i32* %call, null 1219 ret i1 %cmp 1220} 1221 1222define i1 @returns_nonnull_deref_no_null_opt () #0 { 1223; CHECK-LABEL: @returns_nonnull_deref_no_null_opt( 1224; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(4) i32* @returns_nonnull_deref_helper() 1225; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[CALL]], null 1226; CHECK-NEXT: ret i1 [[CMP]] 1227; 1228 %call = call dereferenceable(4) i32* @returns_nonnull_deref_helper() 1229 %cmp = icmp eq i32* %call, null 1230 ret i1 %cmp 1231} 1232 1233declare dereferenceable(4) i32 addrspace(1)* @returns_nonnull_deref_as_helper() 1234define i1 @returns_nonnull_as_deref() { 1235; CHECK-LABEL: @returns_nonnull_as_deref( 1236; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(4) i32 addrspace(1)* @returns_nonnull_deref_as_helper() 1237; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 addrspace(1)* [[CALL]], null 1238; CHECK-NEXT: ret i1 [[CMP]] 1239; 1240 %call = call dereferenceable(4) i32 addrspace(1)* @returns_nonnull_deref_as_helper() 1241 %cmp = icmp eq i32 addrspace(1)* %call, null 1242 ret i1 %cmp 1243} 1244 1245define i1 @nonnull_load(i32** %addr) { 1246; CHECK-LABEL: @nonnull_load( 1247; CHECK-NEXT: ret i1 false 1248; 1249 %ptr = load i32*, i32** %addr, !nonnull !{} 1250 %cmp = icmp eq i32* %ptr, null 1251 ret i1 %cmp 1252} 1253 1254define i1 @nonnull_load_as_outer(i32* addrspace(1)* %addr) { 1255; CHECK-LABEL: @nonnull_load_as_outer( 1256; CHECK-NEXT: ret i1 false 1257; 1258 %ptr = load i32*, i32* addrspace(1)* %addr, !nonnull !{} 1259 %cmp = icmp eq i32* %ptr, null 1260 ret i1 %cmp 1261} 1262define i1 @nonnull_load_as_inner(i32 addrspace(1)** %addr) { 1263; CHECK-LABEL: @nonnull_load_as_inner( 1264; CHECK-NEXT: ret i1 false 1265; 1266 %ptr = load i32 addrspace(1)*, i32 addrspace(1)** %addr, !nonnull !{} 1267 %cmp = icmp eq i32 addrspace(1)* %ptr, null 1268 ret i1 %cmp 1269} 1270 1271; If a bit is known to be zero for A and known to be one for B, 1272; then A and B cannot be equal. 1273define i1 @icmp_eq_const(i32 %a) { 1274; CHECK-LABEL: @icmp_eq_const( 1275; CHECK-NEXT: ret i1 false 1276; 1277 %b = mul nsw i32 %a, -2 1278 %c = icmp eq i32 %b, 1 1279 ret i1 %c 1280} 1281 1282define <2 x i1> @icmp_eq_const_vec(<2 x i32> %a) { 1283; CHECK-LABEL: @icmp_eq_const_vec( 1284; CHECK-NEXT: ret <2 x i1> zeroinitializer 1285; 1286 %b = mul nsw <2 x i32> %a, <i32 -2, i32 -2> 1287 %c = icmp eq <2 x i32> %b, <i32 1, i32 1> 1288 ret <2 x i1> %c 1289} 1290 1291define i1 @icmp_ne_const(i32 %a) { 1292; CHECK-LABEL: @icmp_ne_const( 1293; CHECK-NEXT: ret i1 true 1294; 1295 %b = mul nsw i32 %a, -2 1296 %c = icmp ne i32 %b, 1 1297 ret i1 %c 1298} 1299 1300define <2 x i1> @icmp_ne_const_vec(<2 x i32> %a) { 1301; CHECK-LABEL: @icmp_ne_const_vec( 1302; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true> 1303; 1304 %b = mul nsw <2 x i32> %a, <i32 -2, i32 -2> 1305 %c = icmp ne <2 x i32> %b, <i32 1, i32 1> 1306 ret <2 x i1> %c 1307} 1308 1309define i1 @icmp_sdiv_int_min(i32 %a) { 1310; CHECK-LABEL: @icmp_sdiv_int_min( 1311; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 -2147483648, [[A:%.*]] 1312; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[DIV]], -1073741824 1313; CHECK-NEXT: ret i1 [[CMP]] 1314; 1315 %div = sdiv i32 -2147483648, %a 1316 %cmp = icmp ne i32 %div, -1073741824 1317 ret i1 %cmp 1318 1319} 1320 1321define i1 @icmp_sdiv_pr20288(i64 %a) { 1322; CHECK-LABEL: @icmp_sdiv_pr20288( 1323; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[A:%.*]], -8589934592 1324; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[DIV]], 1073741824 1325; CHECK-NEXT: ret i1 [[CMP]] 1326; 1327 %div = sdiv i64 %a, -8589934592 1328 %cmp = icmp ne i64 %div, 1073741824 1329 ret i1 %cmp 1330 1331} 1332 1333define i1 @icmp_sdiv_neg1(i64 %a) { 1334; CHECK-LABEL: @icmp_sdiv_neg1( 1335; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[A:%.*]], -1 1336; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[DIV]], 1073741824 1337; CHECK-NEXT: ret i1 [[CMP]] 1338; 1339 %div = sdiv i64 %a, -1 1340 %cmp = icmp ne i64 %div, 1073741824 1341 ret i1 %cmp 1342 1343} 1344 1345define i1 @icmp_known_bits(i4 %x, i4 %y) { 1346; CHECK-LABEL: @icmp_known_bits( 1347; CHECK-NEXT: ret i1 false 1348; 1349 %and1 = and i4 %y, -7 1350 %and2 = and i4 %x, -7 1351 %or1 = or i4 %and1, 2 1352 %or2 = or i4 %and2, 2 1353 %add = add i4 %or1, %or2 1354 %cmp = icmp eq i4 %add, 0 1355 ret i1 %cmp 1356} 1357 1358define i1 @icmp_known_bits_vec(<2 x i4> %x, <2 x i4> %y) { 1359; CHECK-LABEL: @icmp_known_bits_vec( 1360; CHECK-NEXT: ret i1 false 1361; 1362 %and1 = and <2 x i4> %y, <i4 -7, i4 -1> 1363 %and2 = and <2 x i4> %x, <i4 -7, i4 -1> 1364 %or1 = or <2 x i4> %and1, <i4 2, i4 2> 1365 %or2 = or <2 x i4> %and2, <i4 2, i4 2> 1366 %add = add <2 x i4> %or1, %or2 1367 %ext = extractelement <2 x i4> %add,i32 0 1368 %cmp = icmp eq i4 %ext, 0 1369 ret i1 %cmp 1370} 1371 1372define i1 @icmp_shl_nuw_1(i64 %a) { 1373; CHECK-LABEL: @icmp_shl_nuw_1( 1374; CHECK-NEXT: ret i1 true 1375; 1376 %shl = shl nuw i64 1, %a 1377 %cmp = icmp ne i64 %shl, 0 1378 ret i1 %cmp 1379 1380} 1381 1382define i1 @icmp_shl_1_V_ugt_2147483648(i32 %V) { 1383; CHECK-LABEL: @icmp_shl_1_V_ugt_2147483648( 1384; CHECK-NEXT: ret i1 false 1385; 1386 %shl = shl i32 1, %V 1387 %cmp = icmp ugt i32 %shl, 2147483648 1388 ret i1 %cmp 1389 1390} 1391 1392define i1 @icmp_shl_1_V_ule_2147483648(i32 %V) { 1393; CHECK-LABEL: @icmp_shl_1_V_ule_2147483648( 1394; CHECK-NEXT: ret i1 true 1395; 1396 %shl = shl i32 1, %V 1397 %cmp = icmp ule i32 %shl, 2147483648 1398 ret i1 %cmp 1399 1400} 1401 1402define i1 @icmp_shl_1_V_eq_31(i32 %V) { 1403; CHECK-LABEL: @icmp_shl_1_V_eq_31( 1404; CHECK-NEXT: ret i1 false 1405; 1406 %shl = shl i32 1, %V 1407 %cmp = icmp eq i32 %shl, 31 1408 ret i1 %cmp 1409 1410} 1411 1412define i1 @icmp_shl_1_V_ne_31(i32 %V) { 1413; CHECK-LABEL: @icmp_shl_1_V_ne_31( 1414; CHECK-NEXT: ret i1 true 1415; 1416 %shl = shl i32 1, %V 1417 %cmp = icmp ne i32 %shl, 31 1418 ret i1 %cmp 1419 1420} 1421 1422define i1 @tautological1(i32 %A, i32 %B) { 1423; CHECK-LABEL: @tautological1( 1424; CHECK-NEXT: ret i1 false 1425; 1426 %C = and i32 %A, %B 1427 %D = icmp ugt i32 %C, %A 1428 ret i1 %D 1429} 1430 1431define i1 @tautological2(i32 %A, i32 %B) { 1432; CHECK-LABEL: @tautological2( 1433; CHECK-NEXT: ret i1 true 1434; 1435 %C = and i32 %A, %B 1436 %D = icmp ule i32 %C, %A 1437 ret i1 %D 1438} 1439 1440define i1 @tautological3(i32 %A, i32 %B) { 1441; CHECK-LABEL: @tautological3( 1442; CHECK-NEXT: ret i1 true 1443; 1444 %C = or i32 %A, %B 1445 %D = icmp ule i32 %A, %C 1446 ret i1 %D 1447} 1448 1449define i1 @tautological4(i32 %A, i32 %B) { 1450; CHECK-LABEL: @tautological4( 1451; CHECK-NEXT: ret i1 false 1452; 1453 %C = or i32 %A, %B 1454 %D = icmp ugt i32 %A, %C 1455 ret i1 %D 1456} 1457 1458define i1 @tautological5(i32 %A, i32 %B) { 1459; CHECK-LABEL: @tautological5( 1460; CHECK-NEXT: ret i1 false 1461; 1462 %C = or i32 %A, %B 1463 %D = icmp ult i32 %C, %A 1464 ret i1 %D 1465} 1466 1467define i1 @tautological6(i32 %A, i32 %B) { 1468; CHECK-LABEL: @tautological6( 1469; CHECK-NEXT: ret i1 true 1470; 1471 %C = or i32 %A, %B 1472 %D = icmp uge i32 %C, %A 1473 ret i1 %D 1474} 1475 1476define i1 @tautological7(i32 %A, i32 %B) { 1477; CHECK-LABEL: @tautological7( 1478; CHECK-NEXT: ret i1 true 1479; 1480 %C = and i32 %A, %B 1481 %D = icmp uge i32 %A, %C 1482 ret i1 %D 1483} 1484 1485define i1 @tautological8(i32 %A, i32 %B) { 1486; CHECK-LABEL: @tautological8( 1487; CHECK-NEXT: ret i1 false 1488; 1489 %C = and i32 %A, %B 1490 %D = icmp ult i32 %A, %C 1491 ret i1 %D 1492} 1493 1494declare void @helper_i1(i1) 1495; Series of tests for icmp s[lt|ge] (or A, B), A and icmp s[gt|le] A, (or A, B) 1496define void @icmp_slt_sge_or(i32 %Ax, i32 %Bx) { 1497; 'p' for positive, 'n' for negative, 'x' for potentially either. 1498; %D is 'icmp slt (or A, B), A' 1499; %E is 'icmp sge (or A, B), A' making it the not of %D 1500; %F is 'icmp sgt A, (or A, B)' making it the same as %D 1501; %G is 'icmp sle A, (or A, B)' making it the not of %D 1502; CHECK-LABEL: @icmp_slt_sge_or( 1503; CHECK-NEXT: [[APOS:%.*]] = and i32 [[AX:%.*]], 2147483647 1504; CHECK-NEXT: [[BNEG:%.*]] = or i32 [[BX:%.*]], -2147483648 1505; CHECK-NEXT: [[CPX:%.*]] = or i32 [[APOS]], [[BX]] 1506; CHECK-NEXT: [[DPX:%.*]] = icmp slt i32 [[CPX]], [[APOS]] 1507; CHECK-NEXT: [[EPX:%.*]] = icmp sge i32 [[CPX]], [[APOS]] 1508; CHECK-NEXT: [[FPX:%.*]] = icmp sgt i32 [[APOS]], [[CPX]] 1509; CHECK-NEXT: [[GPX:%.*]] = icmp sle i32 [[APOS]], [[CPX]] 1510; CHECK-NEXT: [[CXX:%.*]] = or i32 [[AX]], [[BX]] 1511; CHECK-NEXT: [[DXX:%.*]] = icmp slt i32 [[CXX]], [[AX]] 1512; CHECK-NEXT: [[EXX:%.*]] = icmp sge i32 [[CXX]], [[AX]] 1513; CHECK-NEXT: [[FXX:%.*]] = icmp sgt i32 [[AX]], [[CXX]] 1514; CHECK-NEXT: [[GXX:%.*]] = icmp sle i32 [[AX]], [[CXX]] 1515; CHECK-NEXT: [[CXN:%.*]] = or i32 [[AX]], [[BNEG]] 1516; CHECK-NEXT: [[DXN:%.*]] = icmp slt i32 [[CXN]], [[AX]] 1517; CHECK-NEXT: [[EXN:%.*]] = icmp sge i32 [[CXN]], [[AX]] 1518; CHECK-NEXT: [[FXN:%.*]] = icmp sgt i32 [[AX]], [[CXN]] 1519; CHECK-NEXT: [[GXN:%.*]] = icmp sle i32 [[AX]], [[CXN]] 1520; CHECK-NEXT: call void @helper_i1(i1 false) 1521; CHECK-NEXT: call void @helper_i1(i1 true) 1522; CHECK-NEXT: call void @helper_i1(i1 false) 1523; CHECK-NEXT: call void @helper_i1(i1 true) 1524; CHECK-NEXT: call void @helper_i1(i1 [[DPX]]) 1525; CHECK-NEXT: call void @helper_i1(i1 [[EPX]]) 1526; CHECK-NEXT: call void @helper_i1(i1 [[FPX]]) 1527; CHECK-NEXT: call void @helper_i1(i1 [[GPX]]) 1528; CHECK-NEXT: call void @helper_i1(i1 true) 1529; CHECK-NEXT: call void @helper_i1(i1 false) 1530; CHECK-NEXT: call void @helper_i1(i1 true) 1531; CHECK-NEXT: call void @helper_i1(i1 false) 1532; CHECK-NEXT: call void @helper_i1(i1 false) 1533; CHECK-NEXT: call void @helper_i1(i1 true) 1534; CHECK-NEXT: call void @helper_i1(i1 false) 1535; CHECK-NEXT: call void @helper_i1(i1 true) 1536; CHECK-NEXT: call void @helper_i1(i1 [[DXX]]) 1537; CHECK-NEXT: call void @helper_i1(i1 [[EXX]]) 1538; CHECK-NEXT: call void @helper_i1(i1 [[FXX]]) 1539; CHECK-NEXT: call void @helper_i1(i1 [[GXX]]) 1540; CHECK-NEXT: call void @helper_i1(i1 [[DXN]]) 1541; CHECK-NEXT: call void @helper_i1(i1 [[EXN]]) 1542; CHECK-NEXT: call void @helper_i1(i1 [[FXN]]) 1543; CHECK-NEXT: call void @helper_i1(i1 [[GXN]]) 1544; CHECK-NEXT: call void @helper_i1(i1 false) 1545; CHECK-NEXT: call void @helper_i1(i1 true) 1546; CHECK-NEXT: call void @helper_i1(i1 false) 1547; CHECK-NEXT: call void @helper_i1(i1 true) 1548; CHECK-NEXT: call void @helper_i1(i1 false) 1549; CHECK-NEXT: call void @helper_i1(i1 true) 1550; CHECK-NEXT: call void @helper_i1(i1 false) 1551; CHECK-NEXT: call void @helper_i1(i1 true) 1552; CHECK-NEXT: call void @helper_i1(i1 false) 1553; CHECK-NEXT: call void @helper_i1(i1 true) 1554; CHECK-NEXT: call void @helper_i1(i1 false) 1555; CHECK-NEXT: call void @helper_i1(i1 true) 1556; CHECK-NEXT: ret void 1557; 1558 %Aneg = or i32 %Ax, 2147483648 1559 %Apos = and i32 %Ax, 2147483647 1560 %Bneg = or i32 %Bx, 2147483648 1561 %Bpos = and i32 %Bx, 2147483647 1562 1563 %Cpp = or i32 %Apos, %Bpos 1564 %Dpp = icmp slt i32 %Cpp, %Apos 1565 %Epp = icmp sge i32 %Cpp, %Apos 1566 %Fpp = icmp sgt i32 %Apos, %Cpp 1567 %Gpp = icmp sle i32 %Apos, %Cpp 1568 %Cpx = or i32 %Apos, %Bx 1569 %Dpx = icmp slt i32 %Cpx, %Apos 1570 %Epx = icmp sge i32 %Cpx, %Apos 1571 %Fpx = icmp sgt i32 %Apos, %Cpx 1572 %Gpx = icmp sle i32 %Apos, %Cpx 1573 %Cpn = or i32 %Apos, %Bneg 1574 %Dpn = icmp slt i32 %Cpn, %Apos 1575 %Epn = icmp sge i32 %Cpn, %Apos 1576 %Fpn = icmp sgt i32 %Apos, %Cpn 1577 %Gpn = icmp sle i32 %Apos, %Cpn 1578 1579 %Cxp = or i32 %Ax, %Bpos 1580 %Dxp = icmp slt i32 %Cxp, %Ax 1581 %Exp = icmp sge i32 %Cxp, %Ax 1582 %Fxp = icmp sgt i32 %Ax, %Cxp 1583 %Gxp = icmp sle i32 %Ax, %Cxp 1584 %Cxx = or i32 %Ax, %Bx 1585 %Dxx = icmp slt i32 %Cxx, %Ax 1586 %Exx = icmp sge i32 %Cxx, %Ax 1587 %Fxx = icmp sgt i32 %Ax, %Cxx 1588 %Gxx = icmp sle i32 %Ax, %Cxx 1589 %Cxn = or i32 %Ax, %Bneg 1590 %Dxn = icmp slt i32 %Cxn, %Ax 1591 %Exn = icmp sge i32 %Cxn, %Ax 1592 %Fxn = icmp sgt i32 %Ax, %Cxn 1593 %Gxn = icmp sle i32 %Ax, %Cxn 1594 1595 %Cnp = or i32 %Aneg, %Bpos 1596 %Dnp = icmp slt i32 %Cnp, %Aneg 1597 %Enp = icmp sge i32 %Cnp, %Aneg 1598 %Fnp = icmp sgt i32 %Aneg, %Cnp 1599 %Gnp = icmp sle i32 %Aneg, %Cnp 1600 %Cnx = or i32 %Aneg, %Bx 1601 %Dnx = icmp slt i32 %Cnx, %Aneg 1602 %Enx = icmp sge i32 %Cnx, %Aneg 1603 %Fnx = icmp sgt i32 %Aneg, %Cnx 1604 %Gnx = icmp sle i32 %Aneg, %Cnx 1605 %Cnn = or i32 %Aneg, %Bneg 1606 %Dnn = icmp slt i32 %Cnn, %Aneg 1607 %Enn = icmp sge i32 %Cnn, %Aneg 1608 %Fnn = icmp sgt i32 %Aneg, %Cnn 1609 %Gnn = icmp sle i32 %Aneg, %Cnn 1610 1611 call void @helper_i1(i1 %Dpp) 1612 call void @helper_i1(i1 %Epp) 1613 call void @helper_i1(i1 %Fpp) 1614 call void @helper_i1(i1 %Gpp) 1615 call void @helper_i1(i1 %Dpx) 1616 call void @helper_i1(i1 %Epx) 1617 call void @helper_i1(i1 %Fpx) 1618 call void @helper_i1(i1 %Gpx) 1619 call void @helper_i1(i1 %Dpn) 1620 call void @helper_i1(i1 %Epn) 1621 call void @helper_i1(i1 %Fpn) 1622 call void @helper_i1(i1 %Gpn) 1623 call void @helper_i1(i1 %Dxp) 1624 call void @helper_i1(i1 %Exp) 1625 call void @helper_i1(i1 %Fxp) 1626 call void @helper_i1(i1 %Gxp) 1627 call void @helper_i1(i1 %Dxx) 1628 call void @helper_i1(i1 %Exx) 1629 call void @helper_i1(i1 %Fxx) 1630 call void @helper_i1(i1 %Gxx) 1631 call void @helper_i1(i1 %Dxn) 1632 call void @helper_i1(i1 %Exn) 1633 call void @helper_i1(i1 %Fxn) 1634 call void @helper_i1(i1 %Gxn) 1635 call void @helper_i1(i1 %Dnp) 1636 call void @helper_i1(i1 %Enp) 1637 call void @helper_i1(i1 %Fnp) 1638 call void @helper_i1(i1 %Gnp) 1639 call void @helper_i1(i1 %Dnx) 1640 call void @helper_i1(i1 %Enx) 1641 call void @helper_i1(i1 %Fnx) 1642 call void @helper_i1(i1 %Gnx) 1643 call void @helper_i1(i1 %Dnn) 1644 call void @helper_i1(i1 %Enn) 1645 call void @helper_i1(i1 %Fnn) 1646 call void @helper_i1(i1 %Gnn) 1647 ret void 1648} 1649 1650define i1 @constant_fold_inttoptr_null() { 1651; CHECK-LABEL: @constant_fold_inttoptr_null( 1652; CHECK-NEXT: ret i1 false 1653; 1654 %x = icmp eq i32* inttoptr (i64 32 to i32*), null 1655 ret i1 %x 1656} 1657 1658define i1 @constant_fold_null_inttoptr() { 1659; CHECK-LABEL: @constant_fold_null_inttoptr( 1660; CHECK-NEXT: ret i1 false 1661; 1662 %x = icmp eq i32* null, inttoptr (i64 32 to i32*) 1663 ret i1 %x 1664} 1665 1666define i1 @cmp_through_addrspacecast(i32 addrspace(1)* %p1) { 1667; CHECK-LABEL: @cmp_through_addrspacecast( 1668; CHECK-NEXT: ret i1 true 1669; 1670 %p0 = addrspacecast i32 addrspace(1)* %p1 to i32* 1671 %p0.1 = getelementptr inbounds i32, i32* %p0, i64 1 1672 %cmp = icmp ne i32* %p0, %p0.1 1673 ret i1 %cmp 1674} 1675 1676attributes #0 = { "null-pointer-is-valid"="true" } 1677