RFR: 8307084: C2: Vectorized drain loop is not executed for some small trip counts [v4]

Quan Anh Mai qamai at openjdk.org
Fri Jan 30 09:00:43 UTC 2026


On Fri, 30 Jan 2026 08:45:45 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>>> But then we'd still always pay the price of the drain loop, even if it then gets folded away. Not great.
>> 
>> May I ask why? We only need to clone the post loop after we decide to vectorize. At which point it becomes the drain loop, otherwise there is no need for the clone.
>
>> > But then we'd still always pay the price of the drain loop, even if it then gets folded away. Not great.
>> 
>> May I ask why? We only need to clone the post loop after we decide to vectorize. At which point it becomes the drain loop, otherwise there is no need for the clone.
> 
> Ah, I see. So you would do pre/main/post, immediately run the vectorizer on main, if we are about to succeed, clone the post-loop down (possibly multiple times), so we then have some drain loops and a post loop. Then apply the VTransform to the main loop and the drain loops, but with different "vectorization unrolling factors". @merykitty Is that what you are suggesting?

@eme64 Can we clone the post loop after vectorization as well? My thought is that we vectorize and super unroll the main loop. At that point, the maximum iteration of the post loop may become sufficiently large that we clone the post loop, and perform vectorization on the first one.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22629#issuecomment-3822607084


More information about the hotspot-compiler-dev mailing list