Commit 02a015f
VECT: Support CALL vectorization for COND_LEN_*
Hi, Richard and Richi.
Base on the suggestions from Richard:
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/625396.html
This patch choose (1) approach that Richard provided, meaning:
RVV implements cond_* optabs as expanders. RVV therefore supports
both IFN_COND_ADD and IFN_COND_LEN_ADD. No dummy length arguments
are needed at the gimple level.
Such approach can make codes much cleaner and reasonable.
Consider this following case:
void foo (float * __restrict a, float * __restrict b, int * __restrict cond, int n)
{
for (int i = 0; i < n; i++)
if (cond[i])
a[i] = b[i] + a[i];
}
Output of RISC-V (32-bits) gcc (trunk) (Compiler gcc-mirror#3)
<source>:5:21: missed: couldn't vectorize loop
<source>:5:21: missed: not vectorized: control flow in loop.
ARM SVE:
...
mask__27.10_51 = vect__4.9_49 != { 0, ... };
...
vec_mask_and_55 = loop_mask_49 & mask__27.10_51;
...
vect__9.17_62 = .COND_ADD (vec_mask_and_55, vect__6.13_56, vect__8.16_60, vect__6.13_56);
For RVV, we want IR as follows:
...
_68 = .SELECT_VL (ivtmp_66, POLY_INT_CST [4, 4]);
...
mask__27.10_51 = vect__4.9_49 != { 0, ... };
...
vect__9.17_60 = .COND_LEN_ADD (mask__27.10_51, vect__6.13_55, vect__8.16_59, vect__6.13_55, _68, 0);
...
Both len and mask of COND_LEN_ADD are real not dummy.
This patch has been fully tested in RISC-V port with supporting both COND_* and COND_LEN_*.
And also, Bootstrap and Regression on X86 passed.
OK for trunk?
gcc/ChangeLog:
* internal-fn.cc (get_len_internal_fn): New function.
(DEF_INTERNAL_COND_FN): Ditto.
(DEF_INTERNAL_SIGNED_COND_FN): Ditto.
* internal-fn.h (get_len_internal_fn): Ditto.
* tree-vect-stmts.cc (vectorizable_call): Add CALL auto-vectorization.1 parent 31ec413 commit 02a015f
3 files changed
+78
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4443 | 4443 | | |
4444 | 4444 | | |
4445 | 4445 | | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
| 4454 | + | |
| 4455 | + | |
| 4456 | + | |
| 4457 | + | |
| 4458 | + | |
| 4459 | + | |
| 4460 | + | |
| 4461 | + | |
| 4462 | + | |
| 4463 | + | |
| 4464 | + | |
| 4465 | + | |
| 4466 | + | |
| 4467 | + | |
| 4468 | + | |
| 4469 | + | |
4446 | 4470 | | |
4447 | 4471 | | |
4448 | 4472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3540 | 3540 | | |
3541 | 3541 | | |
3542 | 3542 | | |
| 3543 | + | |
| 3544 | + | |
3543 | 3545 | | |
| 3546 | + | |
3544 | 3547 | | |
3545 | 3548 | | |
3546 | 3549 | | |
| |||
3569 | 3572 | | |
3570 | 3573 | | |
3571 | 3574 | | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
3572 | 3578 | | |
3573 | 3579 | | |
3574 | 3580 | | |
| |||
3586 | 3592 | | |
3587 | 3593 | | |
3588 | 3594 | | |
3589 | | - | |
3590 | | - | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
3591 | 3603 | | |
3592 | 3604 | | |
3593 | 3605 | | |
| |||
3603 | 3615 | | |
3604 | 3616 | | |
3605 | 3617 | | |
| 3618 | + | |
3606 | 3619 | | |
3607 | | - | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
3608 | 3632 | | |
3609 | 3633 | | |
3610 | 3634 | | |
| |||
3671 | 3695 | | |
3672 | 3696 | | |
3673 | 3697 | | |
3674 | | - | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
3675 | 3713 | | |
3676 | 3714 | | |
3677 | 3715 | | |
| |||
3719 | 3757 | | |
3720 | 3758 | | |
3721 | 3759 | | |
3722 | | - | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
3723 | 3771 | | |
3724 | 3772 | | |
3725 | 3773 | | |
| |||
0 commit comments