]> git.ipfire.org Git - thirdparty/gcc.git/commit
Vect: use a small step to calculate induction for the unrolled loop (PR tree-optimiza...
authorHao Liu OS <hliu@os.amperecomputing.com>
Thu, 6 Jul 2023 16:04:46 +0000 (10:04 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Thu, 6 Jul 2023 16:04:46 +0000 (10:04 -0600)
commit224fd59b2dc8a5fa78a309a09863afe9b3cf2111
tree4c78a652002dcf12e2e24c935e5e240fbcae5115
parentb90a70984a9beee39b41f842b56926f9db2069ca
Vect: use a small step to calculate induction for the unrolled loop (PR tree-optimization/110449)

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.

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.
gcc/testsuite/gcc.target/aarch64/pr110449.c [new file with mode: 0644]
gcc/tree-vect-loop.cc