1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
|
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s --data-layout="e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck --check-prefixes=ALL,X64 %s
; RUN: opt < %s --data-layout="e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck --check-prefixes=ALL,X32 %s
; While we can't treat inttoptr/ptrtoint casts as fully transparent,
; for ptrtoint cast, instead of modelling it as fully opaque (unknown),
; we can at least model it as zext/trunc/self of an unknown,
; iff it it's argument would be modelled as unknown anyways.
declare void @useptr(i8*)
; Simple ptrtoint of an argument, with casts to potentially different bit widths.
define void @ptrtoint(i8* %in, i64* %out0, i32* %out1, i16* %out2, i128* %out3) {
; X64-LABEL: 'ptrtoint'
; X64-NEXT: Classifying expressions for: @ptrtoint
; X64-NEXT: %p0 = ptrtoint i8* %in to i64
; X64-NEXT: --> (ptrtoint i8* %in to i64) U: full-set S: full-set
; X64-NEXT: %p1 = ptrtoint i8* %in to i32
; X64-NEXT: --> (trunc i64 (ptrtoint i8* %in to i64) to i32) U: full-set S: full-set
; X64-NEXT: %p2 = ptrtoint i8* %in to i16
; X64-NEXT: --> (trunc i64 (ptrtoint i8* %in to i64) to i16) U: full-set S: full-set
; X64-NEXT: %p3 = ptrtoint i8* %in to i128
; X64-NEXT: --> (zext i64 (ptrtoint i8* %in to i64) to i128) U: [0,18446744073709551616) S: [0,18446744073709551616)
; X64-NEXT: Determining loop execution counts for: @ptrtoint
;
; X32-LABEL: 'ptrtoint'
; X32-NEXT: Classifying expressions for: @ptrtoint
; X32-NEXT: %p0 = ptrtoint i8* %in to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8* %in to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: %p1 = ptrtoint i8* %in to i32
; X32-NEXT: --> (ptrtoint i8* %in to i32) U: full-set S: full-set
; X32-NEXT: %p2 = ptrtoint i8* %in to i16
; X32-NEXT: --> (trunc i32 (ptrtoint i8* %in to i32) to i16) U: full-set S: full-set
; X32-NEXT: %p3 = ptrtoint i8* %in to i128
; X32-NEXT: --> (zext i32 (ptrtoint i8* %in to i32) to i128) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint
;
%p0 = ptrtoint i8* %in to i64
%p1 = ptrtoint i8* %in to i32
%p2 = ptrtoint i8* %in to i16
%p3 = ptrtoint i8* %in to i128
store i64 %p0, i64* %out0
store i32 %p1, i32* %out1
store i16 %p2, i16* %out2
store i128 %p3, i128* %out3
ret void
}
; Same, but from non-zero/non-default address space.
define void @ptrtoint_as1(i8 addrspace(1)* %in, i64* %out0, i32* %out1, i16* %out2, i128* %out3) {
; X64-LABEL: 'ptrtoint_as1'
; X64-NEXT: Classifying expressions for: @ptrtoint_as1
; X64-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in to i64
; X64-NEXT: --> (ptrtoint i8 addrspace(1)* %in to i64) U: full-set S: full-set
; X64-NEXT: %p1 = ptrtoint i8 addrspace(1)* %in to i32
; X64-NEXT: --> (trunc i64 (ptrtoint i8 addrspace(1)* %in to i64) to i32) U: full-set S: full-set
; X64-NEXT: %p2 = ptrtoint i8 addrspace(1)* %in to i16
; X64-NEXT: --> (trunc i64 (ptrtoint i8 addrspace(1)* %in to i64) to i16) U: full-set S: full-set
; X64-NEXT: %p3 = ptrtoint i8 addrspace(1)* %in to i128
; X64-NEXT: --> (zext i64 (ptrtoint i8 addrspace(1)* %in to i64) to i128) U: [0,18446744073709551616) S: [0,18446744073709551616)
; X64-NEXT: Determining loop execution counts for: @ptrtoint_as1
;
; X32-LABEL: 'ptrtoint_as1'
; X32-NEXT: Classifying expressions for: @ptrtoint_as1
; X32-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8 addrspace(1)* %in to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: %p1 = ptrtoint i8 addrspace(1)* %in to i32
; X32-NEXT: --> (ptrtoint i8 addrspace(1)* %in to i32) U: full-set S: full-set
; X32-NEXT: %p2 = ptrtoint i8 addrspace(1)* %in to i16
; X32-NEXT: --> (trunc i32 (ptrtoint i8 addrspace(1)* %in to i32) to i16) U: full-set S: full-set
; X32-NEXT: %p3 = ptrtoint i8 addrspace(1)* %in to i128
; X32-NEXT: --> (zext i32 (ptrtoint i8 addrspace(1)* %in to i32) to i128) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_as1
;
%p0 = ptrtoint i8 addrspace(1)* %in to i64
%p1 = ptrtoint i8 addrspace(1)* %in to i32
%p2 = ptrtoint i8 addrspace(1)* %in to i16
%p3 = ptrtoint i8 addrspace(1)* %in to i128
store i64 %p0, i64* %out0
store i32 %p1, i32* %out1
store i16 %p2, i16* %out2
store i128 %p3, i128* %out3
ret void
}
; Likewise, ptrtoint of a bitcast is fine, we simply skip it.
define void @ptrtoint_of_bitcast(i8* %in, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_bitcast'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_bitcast
; X64-NEXT: %in_casted = bitcast i8* %in to float*
; X64-NEXT: --> %in U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint float* %in_casted to i64
; X64-NEXT: --> (ptrtoint i8* %in to i64) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_bitcast
;
; X32-LABEL: 'ptrtoint_of_bitcast'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_bitcast
; X32-NEXT: %in_casted = bitcast i8* %in to float*
; X32-NEXT: --> %in U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint float* %in_casted to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8* %in to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_bitcast
;
%in_casted = bitcast i8* %in to float*
%p0 = ptrtoint float* %in_casted to i64
store i64 %p0, i64* %out0
ret void
}
; addrspacecast is fine too, but We don't model addrspacecast, so we stop there.
define void @ptrtoint_of_addrspacecast(i8* %in, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_addrspacecast'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_addrspacecast
; X64-NEXT: %in_casted = addrspacecast i8* %in to i8 addrspace(1)*
; X64-NEXT: --> %in_casted U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in_casted to i64
; X64-NEXT: --> (ptrtoint i8 addrspace(1)* %in_casted to i64) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_addrspacecast
;
; X32-LABEL: 'ptrtoint_of_addrspacecast'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_addrspacecast
; X32-NEXT: %in_casted = addrspacecast i8* %in to i8 addrspace(1)*
; X32-NEXT: --> %in_casted U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in_casted to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8 addrspace(1)* %in_casted to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_addrspacecast
;
%in_casted = addrspacecast i8* %in to i8 addrspace(1)*
%p0 = ptrtoint i8 addrspace(1)* %in_casted to i64
store i64 %p0, i64* %out0
ret void
}
; inttoptr is fine too, but we don't (and can't) model inttoptr, so we stop there.
define void @ptrtoint_of_inttoptr(i64 %in, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_inttoptr'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_inttoptr
; X64-NEXT: %in_casted = inttoptr i64 %in to i8*
; X64-NEXT: --> %in_casted U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8* %in_casted to i64
; X64-NEXT: --> (ptrtoint i8* %in_casted to i64) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_inttoptr
;
; X32-LABEL: 'ptrtoint_of_inttoptr'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_inttoptr
; X32-NEXT: %in_casted = inttoptr i64 %in to i8*
; X32-NEXT: --> %in_casted U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8* %in_casted to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8* %in_casted to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_inttoptr
;
%in_casted = inttoptr i64 %in to i8*
%p0 = ptrtoint i8* %in_casted to i64
store i64 %p0, i64* %out0
ret void
}
; A constant pointer is fine
define void @ptrtoint_of_nullptr(i64* %out0) {
; ALL-LABEL: 'ptrtoint_of_nullptr'
; ALL-NEXT: Classifying expressions for: @ptrtoint_of_nullptr
; ALL-NEXT: %p0 = ptrtoint i8* null to i64
; ALL-NEXT: --> 0 U: [0,1) S: [0,1)
; ALL-NEXT: Determining loop execution counts for: @ptrtoint_of_nullptr
;
%p0 = ptrtoint i8* null to i64
store i64 %p0, i64* %out0
ret void
}
; A constant inttoptr argument of an ptrtoint is still bad.
define void @ptrtoint_of_constantexpr_inttoptr(i64* %out0) {
; X64-LABEL: 'ptrtoint_of_constantexpr_inttoptr'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_constantexpr_inttoptr
; X64-NEXT: %p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
; X64-NEXT: --> (ptrtoint i8* inttoptr (i64 42 to i8*) to i64) U: [42,43) S: [42,43)
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_constantexpr_inttoptr
;
; X32-LABEL: 'ptrtoint_of_constantexpr_inttoptr'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_constantexpr_inttoptr
; X32-NEXT: %p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8* inttoptr (i64 42 to i8*) to i32) to i64) U: [42,43) S: [42,43)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_constantexpr_inttoptr
;
%p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
store i64 %p0, i64* %out0
ret void
}
; ptrtoint of GEP is fine.
define void @ptrtoint_of_gep(i8* %in, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_gep'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_gep
; X64-NEXT: %in_adj = getelementptr inbounds i8, i8* %in, i64 42
; X64-NEXT: --> (42 + %in) U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8* %in_adj to i64
; X64-NEXT: --> (42 + (ptrtoint i8* %in to i64)) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_gep
;
; X32-LABEL: 'ptrtoint_of_gep'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_gep
; X32-NEXT: %in_adj = getelementptr inbounds i8, i8* %in, i64 42
; X32-NEXT: --> (42 + %in) U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8* %in_adj to i64
; X32-NEXT: --> (zext i32 (42 + (ptrtoint i8* %in to i32)) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_gep
;
%in_adj = getelementptr inbounds i8, i8* %in, i64 42
%p0 = ptrtoint i8* %in_adj to i64
store i64 %p0, i64* %out0
ret void
}
; It seems, we can't get ptrtoint of mul/udiv, or at least it's hard to come up with a test case.
; ptrtoint of AddRec
define void @ptrtoint_of_addrec(i32* %in, i32 %count) {
; X64-LABEL: 'ptrtoint_of_addrec'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_addrec
; X64-NEXT: %i3 = zext i32 %count to i64
; X64-NEXT: --> (zext i32 %count to i64) U: [0,4294967296) S: [0,4294967296)
; X64-NEXT: %i6 = phi i64 [ 0, %entry ], [ %i9, %loop ]
; X64-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: (-1 + (zext i32 %count to i64))<nsw> LoopDispositions: { %loop: Computable }
; X64-NEXT: %i7 = getelementptr inbounds i32, i32* %in, i64 %i6
; X64-NEXT: --> {%in,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * (zext i32 %count to i64))<nuw><nsw> + %in) LoopDispositions: { %loop: Computable }
; X64-NEXT: %i8 = ptrtoint i32* %i7 to i64
; X64-NEXT: --> {(ptrtoint i32* %in to i64),+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * (zext i32 %count to i64))<nuw><nsw> + (ptrtoint i32* %in to i64)) LoopDispositions: { %loop: Computable }
; X64-NEXT: %i9 = add nuw nsw i64 %i6, 1
; X64-NEXT: --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: (zext i32 %count to i64) LoopDispositions: { %loop: Computable }
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_addrec
; X64-NEXT: Loop %loop: backedge-taken count is (-1 + (zext i32 %count to i64))<nsw>
; X64-NEXT: Loop %loop: max backedge-taken count is -1
; X64-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + (zext i32 %count to i64))<nsw>
; X64-NEXT: Predicates:
; X64: Loop %loop: Trip multiple is 1
;
; X32-LABEL: 'ptrtoint_of_addrec'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_addrec
; X32-NEXT: %i3 = zext i32 %count to i64
; X32-NEXT: --> (zext i32 %count to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: %i6 = phi i64 [ 0, %entry ], [ %i9, %loop ]
; X32-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: (-1 + (zext i32 %count to i64))<nsw> LoopDispositions: { %loop: Computable }
; X32-NEXT: %i7 = getelementptr inbounds i32, i32* %in, i64 %i6
; X32-NEXT: --> {%in,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %in) LoopDispositions: { %loop: Computable }
; X32-NEXT: %i8 = ptrtoint i32* %i7 to i64
; X32-NEXT: --> (zext i32 {(ptrtoint i32* %in to i32),+,4}<%loop> to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 (-4 + (4 * %count) + (ptrtoint i32* %in to i32)) to i64) LoopDispositions: { %loop: Computable }
; X32-NEXT: %i9 = add nuw nsw i64 %i6, 1
; X32-NEXT: --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: (zext i32 %count to i64) LoopDispositions: { %loop: Computable }
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_addrec
; X32-NEXT: Loop %loop: backedge-taken count is (-1 + (zext i32 %count to i64))<nsw>
; X32-NEXT: Loop %loop: max backedge-taken count is -1
; X32-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + (zext i32 %count to i64))<nsw>
; X32-NEXT: Predicates:
; X32: Loop %loop: Trip multiple is 1
;
entry:
%i3 = zext i32 %count to i64
br label %loop
loop:
%i6 = phi i64 [ 0, %entry ], [ %i9, %loop ]
%i7 = getelementptr inbounds i32, i32* %in, i64 %i6
%i8 = ptrtoint i32* %i7 to i64
tail call void @use(i64 %i8)
%i9 = add nuw nsw i64 %i6, 1
%i10 = icmp eq i64 %i9, %i3
br i1 %i10, label %end, label %loop
end:
ret void
}
declare void @use(i64)
; ptrtoint of UMax
define void @ptrtoint_of_umax(i8* %in0, i8* %in1, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_umax'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_umax
; X64-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X64-NEXT: --> (%in0 umax %in1) U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8* %s to i64
; X64-NEXT: --> ((ptrtoint i8* %in0 to i64) umax (ptrtoint i8* %in1 to i64)) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_umax
;
; X32-LABEL: 'ptrtoint_of_umax'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_umax
; X32-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X32-NEXT: --> (%in0 umax %in1) U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8* %s to i64
; X32-NEXT: --> (zext i32 ((ptrtoint i8* %in0 to i32) umax (ptrtoint i8* %in1 to i32)) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_umax
;
%c = icmp uge i8* %in0, %in1
%s = select i1 %c, i8* %in0, i8* %in1
%p0 = ptrtoint i8* %s to i64
store i64 %p0, i64* %out0
ret void
}
; ptrtoint of SMax
define void @ptrtoint_of_smax(i8* %in0, i8* %in1, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_smax'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_smax
; X64-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X64-NEXT: --> (%in0 smax %in1) U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8* %s to i64
; X64-NEXT: --> ((ptrtoint i8* %in0 to i64) smax (ptrtoint i8* %in1 to i64)) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_smax
;
; X32-LABEL: 'ptrtoint_of_smax'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_smax
; X32-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X32-NEXT: --> (%in0 smax %in1) U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8* %s to i64
; X32-NEXT: --> (zext i32 ((ptrtoint i8* %in0 to i32) smax (ptrtoint i8* %in1 to i32)) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_smax
;
%c = icmp sge i8* %in0, %in1
%s = select i1 %c, i8* %in0, i8* %in1
%p0 = ptrtoint i8* %s to i64
store i64 %p0, i64* %out0
ret void
}
; ptrtoint of UMin
define void @ptrtoint_of_umin(i8* %in0, i8* %in1, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_umin'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_umin
; X64-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X64-NEXT: --> (%in0 umin %in1) U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8* %s to i64
; X64-NEXT: --> ((ptrtoint i8* %in0 to i64) umin (ptrtoint i8* %in1 to i64)) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_umin
;
; X32-LABEL: 'ptrtoint_of_umin'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_umin
; X32-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X32-NEXT: --> (%in0 umin %in1) U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8* %s to i64
; X32-NEXT: --> (zext i32 ((ptrtoint i8* %in0 to i32) umin (ptrtoint i8* %in1 to i32)) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_umin
;
%c = icmp ule i8* %in0, %in1
%s = select i1 %c, i8* %in0, i8* %in1
%p0 = ptrtoint i8* %s to i64
store i64 %p0, i64* %out0
ret void
}
; ptrtoint of SMin
define void @ptrtoint_of_smin(i8* %in0, i8* %in1, i64* %out0) {
; X64-LABEL: 'ptrtoint_of_smin'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_smin
; X64-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X64-NEXT: --> (%in0 smin %in1) U: full-set S: full-set
; X64-NEXT: %p0 = ptrtoint i8* %s to i64
; X64-NEXT: --> ((ptrtoint i8* %in0 to i64) smin (ptrtoint i8* %in1 to i64)) U: full-set S: full-set
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_smin
;
; X32-LABEL: 'ptrtoint_of_smin'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_smin
; X32-NEXT: %s = select i1 %c, i8* %in0, i8* %in1
; X32-NEXT: --> (%in0 smin %in1) U: full-set S: full-set
; X32-NEXT: %p0 = ptrtoint i8* %s to i64
; X32-NEXT: --> (zext i32 ((ptrtoint i8* %in0 to i32) smin (ptrtoint i8* %in1 to i32)) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_smin
;
%c = icmp sle i8* %in0, %in1
%s = select i1 %c, i8* %in0, i8* %in1
%p0 = ptrtoint i8* %s to i64
store i64 %p0, i64* %out0
ret void
}
; void pr46786_c26_char(char* start, char *end, char *other) {
; for (char* cur = start; cur != end; ++cur)
; other[cur - start] += *cur;
; }
define void @pr46786_c26_char(i8* %arg, i8* %arg1, i8* %arg2) {
; X64-LABEL: 'pr46786_c26_char'
; X64-NEXT: Classifying expressions for: @pr46786_c26_char
; X64-NEXT: %i4 = ptrtoint i8* %arg to i64
; X64-NEXT: --> (ptrtoint i8* %arg to i64) U: full-set S: full-set
; X64-NEXT: %i7 = phi i8* [ %arg, %bb3 ], [ %i14, %bb6 ]
; X64-NEXT: --> {%arg,+,1}<nuw><%bb6> U: full-set S: full-set Exits: (-1 + (-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64) + %arg) LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i8 = load i8, i8* %i7, align 1
; X64-NEXT: --> %i8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i9 = ptrtoint i8* %i7 to i64
; X64-NEXT: --> {(ptrtoint i8* %arg to i64),+,1}<nuw><%bb6> U: full-set S: full-set Exits: (-1 + (ptrtoint i8* %arg1 to i64)) LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i10 = sub i64 %i9, %i4
; X64-NEXT: --> {0,+,1}<nuw><%bb6> U: full-set S: full-set Exits: (-1 + (-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64)) LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i11 = getelementptr inbounds i8, i8* %arg2, i64 %i10
; X64-NEXT: --> {%arg2,+,1}<nw><%bb6> U: full-set S: full-set Exits: (-1 + (-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64) + %arg2) LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i12 = load i8, i8* %i11, align 1
; X64-NEXT: --> %i12 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i13 = add i8 %i12, %i8
; X64-NEXT: --> (%i12 + %i8) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i14 = getelementptr inbounds i8, i8* %i7, i64 1
; X64-NEXT: --> {(1 + %arg),+,1}<nuw><%bb6> U: full-set S: full-set Exits: ((-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64) + %arg) LoopDispositions: { %bb6: Computable }
; X64-NEXT: Determining loop execution counts for: @pr46786_c26_char
; X64-NEXT: Loop %bb6: backedge-taken count is (-1 + (-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64))
; X64-NEXT: Loop %bb6: max backedge-taken count is -1
; X64-NEXT: Loop %bb6: Predicated backedge-taken count is (-1 + (-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64))
; X64-NEXT: Predicates:
; X64: Loop %bb6: Trip multiple is 1
;
; X32-LABEL: 'pr46786_c26_char'
; X32-NEXT: Classifying expressions for: @pr46786_c26_char
; X32-NEXT: %i4 = ptrtoint i8* %arg to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8* %arg to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: %i7 = phi i8* [ %arg, %bb3 ], [ %i14, %bb6 ]
; X32-NEXT: --> {%arg,+,1}<nuw><%bb6> U: full-set S: full-set Exits: (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32) + %arg) LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i8 = load i8, i8* %i7, align 1
; X32-NEXT: --> %i8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i9 = ptrtoint i8* %i7 to i64
; X32-NEXT: --> {(zext i32 (ptrtoint i8* %arg to i32) to i64),+,1}<nuw><%bb6> U: [0,8589934591) S: [0,8589934591) Exits: ((zext i32 (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32)) to i64) + (zext i32 (ptrtoint i8* %arg to i32) to i64)) LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i10 = sub i64 %i9, %i4
; X32-NEXT: --> {0,+,1}<nuw><%bb6> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32)) to i64) LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i11 = getelementptr inbounds i8, i8* %arg2, i64 %i10
; X32-NEXT: --> {%arg2,+,1}<%bb6> U: full-set S: full-set Exits: (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32) + %arg2) LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i12 = load i8, i8* %i11, align 1
; X32-NEXT: --> %i12 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i13 = add i8 %i12, %i8
; X32-NEXT: --> (%i12 + %i8) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i14 = getelementptr inbounds i8, i8* %i7, i64 1
; X32-NEXT: --> {(1 + %arg),+,1}<nuw><%bb6> U: full-set S: full-set Exits: ((-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32) + %arg) LoopDispositions: { %bb6: Computable }
; X32-NEXT: Determining loop execution counts for: @pr46786_c26_char
; X32-NEXT: Loop %bb6: backedge-taken count is (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32))
; X32-NEXT: Loop %bb6: max backedge-taken count is -1
; X32-NEXT: Loop %bb6: Predicated backedge-taken count is (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32))
; X32-NEXT: Predicates:
; X32: Loop %bb6: Trip multiple is 1
;
%i = icmp eq i8* %arg, %arg1
br i1 %i, label %bb5, label %bb3
bb3:
%i4 = ptrtoint i8* %arg to i64
br label %bb6
bb6:
%i7 = phi i8* [ %arg, %bb3 ], [ %i14, %bb6 ]
%i8 = load i8, i8* %i7
%i9 = ptrtoint i8* %i7 to i64
%i10 = sub i64 %i9, %i4
%i11 = getelementptr inbounds i8, i8* %arg2, i64 %i10
%i12 = load i8, i8* %i11
%i13 = add i8 %i12, %i8
store i8 %i13, i8* %i11
%i14 = getelementptr inbounds i8, i8* %i7, i64 1
%i15 = icmp eq i8* %i14, %arg1
br i1 %i15, label %bb5, label %bb6
bb5:
ret void
}
; void pr46786_c26_int(int* start, int *end, int *other) {
; for (int* cur = start; cur != end; ++cur)
; other[cur - start] += *cur;
; }
;
; FIXME: 4 * (%i10 EXACT/s 4) is just %i10
define void @pr46786_c26_int(i32* %arg, i32* %arg1, i32* %arg2) {
; X64-LABEL: 'pr46786_c26_int'
; X64-NEXT: Classifying expressions for: @pr46786_c26_int
; X64-NEXT: %i4 = ptrtoint i32* %arg to i64
; X64-NEXT: --> (ptrtoint i32* %arg to i64) U: full-set S: full-set
; X64-NEXT: %i7 = phi i32* [ %arg, %bb3 ], [ %i15, %bb6 ]
; X64-NEXT: --> {%arg,+,4}<nuw><%bb6> U: full-set S: full-set Exits: ((4 * ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4))<nuw> + %arg) LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i8 = load i32, i32* %i7, align 4
; X64-NEXT: --> %i8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i9 = ptrtoint i32* %i7 to i64
; X64-NEXT: --> {(ptrtoint i32* %arg to i64),+,4}<nuw><%bb6> U: full-set S: full-set Exits: ((4 * ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4))<nuw> + (ptrtoint i32* %arg to i64)) LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i10 = sub i64 %i9, %i4
; X64-NEXT: --> {0,+,4}<nuw><%bb6> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4))<nuw> LoopDispositions: { %bb6: Computable }
; X64-NEXT: %i11 = ashr exact i64 %i10, 2
; X64-NEXT: --> %i11 U: [-2305843009213693952,2305843009213693952) S: [-2305843009213693952,2305843009213693952) Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i12 = getelementptr inbounds i32, i32* %arg2, i64 %i11
; X64-NEXT: --> ((4 * %i11)<nsw> + %arg2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i13 = load i32, i32* %i12, align 4
; X64-NEXT: --> %i13 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i14 = add nsw i32 %i13, %i8
; X64-NEXT: --> (%i13 + %i8) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X64-NEXT: %i15 = getelementptr inbounds i32, i32* %i7, i64 1
; X64-NEXT: --> {(4 + %arg),+,4}<nuw><%bb6> U: full-set S: full-set Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4))<nuw> + %arg) LoopDispositions: { %bb6: Computable }
; X64-NEXT: Determining loop execution counts for: @pr46786_c26_int
; X64-NEXT: Loop %bb6: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4)
; X64-NEXT: Loop %bb6: max backedge-taken count is 4611686018427387903
; X64-NEXT: Loop %bb6: Predicated backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4)
; X64-NEXT: Predicates:
; X64: Loop %bb6: Trip multiple is 1
;
; X32-LABEL: 'pr46786_c26_int'
; X32-NEXT: Classifying expressions for: @pr46786_c26_int
; X32-NEXT: %i4 = ptrtoint i32* %arg to i64
; X32-NEXT: --> (zext i32 (ptrtoint i32* %arg to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: %i7 = phi i32* [ %arg, %bb3 ], [ %i15, %bb6 ]
; X32-NEXT: --> {%arg,+,4}<nuw><%bb6> U: full-set S: full-set Exits: ((4 * ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4))<nuw> + %arg) LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i8 = load i32, i32* %i7, align 4
; X32-NEXT: --> %i8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i9 = ptrtoint i32* %i7 to i64
; X32-NEXT: --> {(zext i32 (ptrtoint i32* %arg to i32) to i64),+,4}<nuw><%bb6> U: [0,8589934588) S: [0,8589934588) Exits: ((zext i32 (ptrtoint i32* %arg to i32) to i64) + (4 * ((zext i32 (-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) to i64) /u 4))<nuw><nsw>) LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i10 = sub i64 %i9, %i4
; X32-NEXT: --> {0,+,4}<nuw><%bb6> U: [0,4294967293) S: [0,4294967293) Exits: (4 * ((zext i32 (-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) to i64) /u 4))<nuw><nsw> LoopDispositions: { %bb6: Computable }
; X32-NEXT: %i11 = ashr exact i64 %i10, 2
; X32-NEXT: --> %i11 U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i12 = getelementptr inbounds i32, i32* %arg2, i64 %i11
; X32-NEXT: --> ((4 * (trunc i64 %i11 to i32))<nsw> + %arg2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i13 = load i32, i32* %i12, align 4
; X32-NEXT: --> %i13 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i14 = add nsw i32 %i13, %i8
; X32-NEXT: --> (%i13 + %i8) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb6: Variant }
; X32-NEXT: %i15 = getelementptr inbounds i32, i32* %i7, i64 1
; X32-NEXT: --> {(4 + %arg),+,4}<nuw><%bb6> U: full-set S: full-set Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4))<nuw> + %arg) LoopDispositions: { %bb6: Computable }
; X32-NEXT: Determining loop execution counts for: @pr46786_c26_int
; X32-NEXT: Loop %bb6: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4)
; X32-NEXT: Loop %bb6: max backedge-taken count is 1073741823
; X32-NEXT: Loop %bb6: Predicated backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4)
; X32-NEXT: Predicates:
; X32: Loop %bb6: Trip multiple is 1
;
%i = icmp eq i32* %arg, %arg1
br i1 %i, label %bb5, label %bb3
bb3:
%i4 = ptrtoint i32* %arg to i64
br label %bb6
bb6:
%i7 = phi i32* [ %arg, %bb3 ], [ %i15, %bb6 ]
%i8 = load i32, i32* %i7
%i9 = ptrtoint i32* %i7 to i64
%i10 = sub i64 %i9, %i4
%i11 = ashr exact i64 %i10, 2
%i12 = getelementptr inbounds i32, i32* %arg2, i64 %i11
%i13 = load i32, i32* %i12
%i14 = add nsw i32 %i13, %i8
store i32 %i14, i32* %i12
%i15 = getelementptr inbounds i32, i32* %i7, i64 1
%i16 = icmp eq i32* %i15, %arg1
br i1 %i16, label %bb5, label %bb6
bb5:
ret void
}
; During SCEV rewrites, we could end up calling `ScalarEvolution::getPtrToIntExpr()`
; on an integer. Make sure we handle that case gracefully.
define void @ptrtoint_of_integer(i8* %arg, i64 %arg1, i1 %arg2) local_unnamed_addr {
; X64-LABEL: 'ptrtoint_of_integer'
; X64-NEXT: Classifying expressions for: @ptrtoint_of_integer
; X64-NEXT: %i4 = ptrtoint i8* %arg to i64
; X64-NEXT: --> (ptrtoint i8* %arg to i64) U: full-set S: full-set
; X64-NEXT: %i6 = sub i64 %i4, %arg1
; X64-NEXT: --> ((-1 * %arg1) + (ptrtoint i8* %arg to i64)) U: full-set S: full-set
; X64-NEXT: %i9 = phi i64 [ 1, %bb7 ], [ %i11, %bb10 ]
; X64-NEXT: --> {1,+,1}<nuw><%bb8> U: [1,0) S: [1,0) Exits: <<Unknown>> LoopDispositions: { %bb8: Computable }
; X64-NEXT: %i11 = add nuw i64 %i9, 1
; X64-NEXT: --> {2,+,1}<nw><%bb8> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb8: Computable }
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_integer
; X64-NEXT: Loop %bb8: <multiple exits> Unpredictable backedge-taken count.
; X64-NEXT: exit count for bb8: ***COULDNOTCOMPUTE***
; X64-NEXT: exit count for bb10: (-2 + (-1 * %arg1) + (ptrtoint i8* %arg to i64))
; X64-NEXT: Loop %bb8: max backedge-taken count is -1
; X64-NEXT: Loop %bb8: Unpredictable predicated backedge-taken count.
;
; X32-LABEL: 'ptrtoint_of_integer'
; X32-NEXT: Classifying expressions for: @ptrtoint_of_integer
; X32-NEXT: %i4 = ptrtoint i8* %arg to i64
; X32-NEXT: --> (zext i32 (ptrtoint i8* %arg to i32) to i64) U: [0,4294967296) S: [0,4294967296)
; X32-NEXT: %i6 = sub i64 %i4, %arg1
; X32-NEXT: --> ((zext i32 (ptrtoint i8* %arg to i32) to i64) + (-1 * %arg1)) U: full-set S: full-set
; X32-NEXT: %i9 = phi i64 [ 1, %bb7 ], [ %i11, %bb10 ]
; X32-NEXT: --> {1,+,1}<nuw><%bb8> U: [1,0) S: [1,0) Exits: <<Unknown>> LoopDispositions: { %bb8: Computable }
; X32-NEXT: %i11 = add nuw i64 %i9, 1
; X32-NEXT: --> {2,+,1}<nw><%bb8> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb8: Computable }
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_integer
; X32-NEXT: Loop %bb8: <multiple exits> Unpredictable backedge-taken count.
; X32-NEXT: exit count for bb8: ***COULDNOTCOMPUTE***
; X32-NEXT: exit count for bb10: (-2 + (zext i32 (ptrtoint i8* %arg to i32) to i64) + (-1 * %arg1))
; X32-NEXT: Loop %bb8: max backedge-taken count is -1
; X32-NEXT: Loop %bb8: Unpredictable predicated backedge-taken count.
;
bb:
%i = icmp eq i8* %arg, null
br i1 %i, label %bb14, label %bb3
bb3: ; preds = %bb
%i4 = ptrtoint i8* %arg to i64
br label %bb5
bb5: ; preds = %bb3
%i6 = sub i64 %i4, %arg1
br label %bb7
bb7: ; preds = %bb5
br label %bb8
bb8: ; preds = %bb10, %bb7
%i9 = phi i64 [ 1, %bb7 ], [ %i11, %bb10 ]
br i1 %arg2, label %bb10, label %bb13
bb10: ; preds = %bb8
%i11 = add nuw i64 %i9, 1
%i12 = icmp eq i64 %i11, %i6
br i1 %i12, label %bb13, label %bb8
bb13: ; preds = %bb10, %bb8
ret void
bb14: ; preds = %bb
ret void
}
|