On 7/6/23 06:44, Richard Biener via Gcc-patches wrote:
On Wed, Jul 5, 2023 at 8:44 AM Hao Liu OS via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:

Hi,

If a loop is unrolled by n times during vectoriation, two steps are used to
calculate the induction variable:
   - The small step for the unrolled ith-copy: vec_1 = vec_iv + (VF/n * Step)
   - The large step for the whole loop: vec_loop = vec_iv + (VF * Step)

This patch calculates an extra vec_n to replace vec_loop:
   vec_n = vec_prev + (VF/n * S) = vec_iv + (VF/n * S) * n = vec_loop.

So that we can save the large step register and related operations.

OK.  It would be nice to avoid the dead stmts created earlier though.

Thanks,
Richard.

gcc/ChangeLog:

         PR tree-optimization/110449
         * tree-vect-loop.cc (vectorizable_induction): use vec_n to replace
         vec_loop for the unrolled loop.

gcc/testsuite/ChangeLog:

         * gcc.target/aarch64/pr110449.c: New testcase.
I didn't see Hao Liu in the MAINTAINERS file, so probably doesn't have write access. Therefore I went ahead and pushed this for Hao.

jeff

Reply via email to