]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: replace log_vf usages with vf to allow support for non-power of two vf
authorTamar Christina <tamar.christina@arm.com>
Tue, 24 Jun 2025 06:13:22 +0000 (07:13 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 24 Jun 2025 06:13:22 +0000 (07:13 +0100)
commit309dbcea2cabb31bde1a65cdfd30bb7f87b170a2
tree2554b47594d229ffb1bb5da754ebf16ebe7a5051
parentaba3b9d3a48a0703fd565f7c5f0caf604f59970b
middle-end: replace log_vf usages with vf to allow support for non-power of two vf

This patch fixes a bug where the current code assumed that exact_log2 returns
NULL on failure, but it instead returns -1.  So there are some cases where the
right shift could shift out the entire value.

Secondly it also removes the requirement that VF be a power of two.  With an
uneven unroll factor we can easily end up with a non-power of two VF which SLP
can handle. This replaces shifts with multiplication and division.

The 32-bit x86 testcase from PR64110 was always wrong, it used to match by pure
coincidence a vmovd inside the vector loop.  What it intended to match was that
the argument to the function isn't spilled and then reloaded from the stack for
no reason.

But on 32-bit x86 all arguments are passed on the stack anyway and so the match
would have never worked.  The patch seems to simplify the loop preheader which
gets it to remove an intermediate zero extend which causes the match to now
properly fail.

As such I'm skipping the test on 32-bit x86.

gcc/ChangeLog:

* tree-vect-loop-manip.cc (vect_gen_vector_loop_niters,
vect_gen_vector_loop_niters_mult_vf): Remove uses of log_vf.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr64110.c: Update testcase.
gcc/testsuite/gcc.target/i386/pr64110.c
gcc/tree-vect-loop-manip.cc