vect: Fold LEN_{LOAD,STORE} if it's for the whole vector [PR107412]
authorKewen Lin <linkw@linux.ibm.com>
Mon, 7 Nov 2022 08:07:27 +0000 (02:07 -0600)
committerKewen Lin <linkw@linux.ibm.com>
Mon, 7 Nov 2022 08:07:27 +0000 (02:07 -0600)
commit8408120fecc56385b316dafec1bdfe3aac61fc05
treee3908485afbce699af140ca7636af383e498c266
parentc4f8f8afd07680f9e718de1331cd09607bdd9ac8
vect: Fold LEN_{LOAD,STORE} if it's for the whole vector [PR107412]

As the test case in PR107412 shows, we can fold IFN .LEN_{LOAD,
STORE} into normal vector load/store if the given length is known
to be equal to the length of the whole vector.  It would help to
improve overall cycles as normally the latency of vector access
with length in bytes is bigger than normal vector access, and it
also saves the preparation for length if constant length can not
be encoded into instruction (such as on power).

PR tree-optimization/107412

gcc/ChangeLog:

* gimple-fold.cc (gimple_fold_mask_load_store_mem_ref): Rename to ...
(gimple_fold_partial_load_store_mem_ref): ... this, add one parameter
mask_p indicating it's for mask or length, and add some handlings for
IFN LEN_{LOAD,STORE}.
(gimple_fold_mask_load): Rename to ...
(gimple_fold_partial_load): ... this, add one parameter mask_p.
(gimple_fold_mask_store): Rename to ...
(gimple_fold_partial_store): ... this, add one parameter mask_p.
(gimple_fold_call): Add the handlings for IFN LEN_{LOAD,STORE},
and adjust calls on gimple_fold_mask_load_store_mem_ref to
gimple_fold_partial_load_store_mem_ref.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr107412.c: New test.
* gcc.target/powerpc/p9-vec-length-epil-8.c: Adjust scan times for
folded LEN_LOAD.
gcc/gimple-fold.cc
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
gcc/testsuite/gcc.target/powerpc/pr107412.c [new file with mode: 0644]