Hi all,
Currently the LoopVectorizer
has a lack of functionality due to missing metadata of individual control to the “vectorization component” and “loop-interleave component” of LoopVectorizer
. Please consider the following problem and the proposed approach.
Problem statement and goal
Current behavior for metadata
The LoopVectorizer
(abbreviating the pass as LV
in this RFC) performs vectorization and loop-interleave. Here we enumerate how LV
behaves for the existing metadata.
To disable the whole LV
:
{loop.vectorize.enable, false}
To disable vectorization of LV
:
{loop.vectorize.width, 1}
To disable loop-interleave of LV
:
{loop.interleave.width, 1}
To enable vectorization of LV
:
{loop.vectorize.width, x} // where x != 1
To enable loop-interleave of LV
:
{loop.interleave.width, x} // where x != 1
Problem of current behavior
Vectorization of width 1, although may be inefficient, should still be a possible specification for the LoopVectorizer. The LV
cannot do this because it thinks that vectorize.width == 1
is to disable vectorization for LV
.
Approach
This RFC wants to propose two new metadata loop.vectorization.enable
and loop.interleave.enable
that gives individual control to vectorization and loop-interleave in LV
. The individual control of metadata solves the problem naturally since now LV
can distinguish when the vectorization is disabled in another way.
We want the LLVM IR to be backward compatible, so the current behaviors stay “as-is”. The new metadata only provides an extra way to do what we already can now and additionally lets LV
vectorize with width of 1.
To disable the whole LV
:
// Current way
{loop.vectorize.enable, false}
// With this RFC
{loop.vectorization.enable, false}
{loop.vectorization.disable, false}
To disable vectorization of LV
:
// Current way
{loop.vectorize.width, 1}
// With this RFC
{loop.vectorization.enable, false}
To disable loop-interleave of LV
:
// Current way
{loop.interleave.width, 1}
// With this RFC
{loop.interleave.enable, false}
To enable vectorization of LV
:
// Current way
{loop.vectorize.width, x} // where x != 1
// With this RFC
{loop.vectorization.enable, true}
{loop.vectorize.width, x} // x can be any non-negative integer
To enable loop-interleave of LV
:
// Current way
{loop.interleave.width, x} // where x != 1
// With this RFC
{loop.interleave.enable, true}
{loop.interleave.width, x} // x can be any non-negative integer (but meaningless when x == 1)
To let LV
vectorize with width 1:
// Current way
N/A
// With this RFC
{loop.vectorization.enable, true}
{loop.vectorize.width, 1}
Thank you for your time reading this letter, all comments are welcomed.
Regards,
eop Chen