Commit ca0c5ce
committed
[LoopVectorize][LAA] Hoist load in memory IV to allow vectorization
Adds VPScalarIVPromotionRecipe recipe to promote memory IV to scalar
IV.
Use SCEV mutilplied by VFxUF or EVL to multiply the SCEV between load
and store.
The code that this patch allows vectorization is like this:
while.body:
%theFirst.addr.0112 = phi ptr [ %incdec.ptr9, %while.body ], [ %theFirst, %while.body.preheader ]
%thePointer.0111 = phi ptr [ %incdec.ptr, %while.body ], [ %add.ptr.i, %while.body.preheader ]
%1 = load i16, ptr %theFirst.addr.0112, align 2
store i16 %1, ptr %thePointer.0111, align 2
%incdec.ptr = getelementptr inbounds nuw i8, ptr %thePointer.0111, i64 2
%2 = load i64, ptr %m_size_ptr, align 8
%inc = add i64 %2, 1
store i64 %inc, ptr %m_size_ptr, align 8
%incdec.ptr9 = getelementptr inbounds nuw i8, ptr %theFirst.addr.0112, i64 2
%cmp7.not = icmp eq ptr %incdec.ptr9, %theLast
br i1 %cmp7.not, label %cleanup.loopexit, label %while.body
As you can see, %m_size_ptr is a loop invariant pointer and can be
promoted to a IV scalar and then execute vectorization.1 parent e86d562 commit ca0c5ce
File tree
37 files changed
+463
-213
lines changed- llvm
- lib
- Analysis
- Transforms
- Scalar
- Vectorize
- test
- Analysis/LoopAccessAnalysis
- Transforms/LoopVectorize
- AArch64
- RISCV
- X86
37 files changed
+463
-213
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2329 | 2329 | | |
2330 | 2330 | | |
2331 | 2331 | | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
2332 | 2345 | | |
2333 | 2346 | | |
2334 | 2347 | | |
| |||
2942 | 2955 | | |
2943 | 2956 | | |
2944 | 2957 | | |
2945 | | - | |
2946 | | - | |
2947 | | - | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
2948 | 2967 | | |
2949 | 2968 | | |
2950 | 2969 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
683 | | - | |
| 683 | + | |
| 684 | + | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
687 | 688 | | |
688 | | - | |
| 689 | + | |
| 690 | + | |
689 | 691 | | |
690 | 692 | | |
691 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| 633 | + | |
| 634 | + | |
633 | 635 | | |
634 | 636 | | |
635 | 637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4092 | 4092 | | |
4093 | 4093 | | |
4094 | 4094 | | |
| 4095 | + | |
4095 | 4096 | | |
4096 | 4097 | | |
4097 | 4098 | | |
| |||
7523 | 7524 | | |
7524 | 7525 | | |
7525 | 7526 | | |
| 7527 | + | |
| 7528 | + | |
| 7529 | + | |
| 7530 | + | |
| 7531 | + | |
| 7532 | + | |
| 7533 | + | |
| 7534 | + | |
7526 | 7535 | | |
7527 | 7536 | | |
7528 | 7537 | | |
| |||
7532 | 7541 | | |
7533 | 7542 | | |
7534 | 7543 | | |
| 7544 | + | |
7535 | 7545 | | |
7536 | 7546 | | |
7537 | 7547 | | |
| |||
8324 | 8334 | | |
8325 | 8335 | | |
8326 | 8336 | | |
| 8337 | + | |
| 8338 | + | |
| 8339 | + | |
| 8340 | + | |
| 8341 | + | |
| 8342 | + | |
| 8343 | + | |
| 8344 | + | |
| 8345 | + | |
| 8346 | + | |
| 8347 | + | |
| 8348 | + | |
| 8349 | + | |
| 8350 | + | |
| 8351 | + | |
| 8352 | + | |
| 8353 | + | |
8327 | 8354 | | |
8328 | 8355 | | |
8329 | 8356 | | |
| |||
8434 | 8461 | | |
8435 | 8462 | | |
8436 | 8463 | | |
8437 | | - | |
8438 | | - | |
| 8464 | + | |
| 8465 | + | |
8439 | 8466 | | |
8440 | 8467 | | |
8441 | | - | |
| 8468 | + | |
| 8469 | + | |
8442 | 8470 | | |
8443 | 8471 | | |
8444 | 8472 | | |
| |||
8514 | 8542 | | |
8515 | 8543 | | |
8516 | 8544 | | |
| 8545 | + | |
| 8546 | + | |
8517 | 8547 | | |
8518 | 8548 | | |
8519 | 8549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
557 | 558 | | |
558 | 559 | | |
559 | 560 | | |
| |||
580 | 581 | | |
581 | 582 | | |
582 | 583 | | |
583 | | - | |
| 584 | + | |
| 585 | + | |
584 | 586 | | |
585 | 587 | | |
586 | | - | |
| 588 | + | |
| 589 | + | |
587 | 590 | | |
588 | 591 | | |
589 | 592 | | |
| |||
2312 | 2315 | | |
2313 | 2316 | | |
2314 | 2317 | | |
2315 | | - | |
| 2318 | + | |
| 2319 | + | |
2316 | 2320 | | |
2317 | 2321 | | |
2318 | 2322 | | |
| |||
3475 | 3479 | | |
3476 | 3480 | | |
3477 | 3481 | | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
3478 | 3530 | | |
3479 | 3531 | | |
3480 | 3532 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| |||
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
292 | | - | |
293 | | - | |
294 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| |||
0 commit comments