]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: clear the user unroll flag if the cost model has overriden it
authorTamar Christina <tamar.christina@arm.com>
Fri, 12 Sep 2025 07:28:44 +0000 (08:28 +0100)
committerTamar Christina <tamar.christina@arm.com>
Fri, 12 Sep 2025 07:28:44 +0000 (08:28 +0100)
commit0ee908659e7416a9214250cb15237f9effe315f0
tree79dbbfc7865b6746d7b4ce9c8b5dc63e14cd0046
parent2343cc8d04bf5c120e61126c375f87c0eb93b6b0
middle-end: clear the user unroll flag if the cost model has overriden it

If the user has requested loop unrolling through pragma GCC unroll then at the
moment we only set LOOP_VINFO_USER_UNROLL if the vectorizer has not overrode the
unroll factor (through backend costing) or if the VF made the requested unroll
factor be 1.

When we have a loop of say int and a pragma unroll 4

If the vectorizer picks V4SI as the mode, the requested unroll ended up exactly
matching the VF. As such the requested unroll is 1 and we don't clear the pragma.

So it did honor the requested unroll factor. However since we didn't set the
unroll amount back and left it at 4 the rtl unroller won't use the rtl cost
model at all and just unroll the vector loop 4 times.

But of these events are costing related, and so it stands to reason that we
should set LOOP_VINFO_USER_UNROLL to we return the RTL unroller to use the
backend costing for any further unrolling.

gcc/ChangeLog:

* tree-vect-loop.cc (vect_analyze_loop_1): If the unroll pragma was set
mark it as handled.
* doc/extend.texi (pragma GCC unroll): Update documentation.
gcc/doc/extend.texi
gcc/tree-vect-loop.cc