RFR: 8342095: Add autovectorizer support for subword vector casts [v15]
Jasmine Karthikeyan
jkarthikeyan at openjdk.org
Tue Jan 27 03:12:35 UTC 2026
On Fri, 23 Jan 2026 08:40:53 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Jasmine Karthikeyan has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 19 commits:
>>
>> - Fix whitespace
>> - Update tests after merge, apply changes from review
>> - Merge from master
>> - Update tests, cleanup logic
>> - Merge branch 'master' into vectorize-subword
>> - Check for AVX2 for byte/long conversions
>> - Whitespace and benchmark tweak
>> - Address more comments, make test and benchmark more exhaustive
>> - Merge from master
>> - Fix copyright after merge
>> - ... and 9 more: https://git.openjdk.org/jdk/compare/de6f35ef...13378368
>
> src/hotspot/share/opto/superwordVTransformBuilder.cpp line 264:
>
>> 262: if (use_bt != def_bt && !p0->is_Convert() && VectorCastNode::is_supported_subword_cast(def_bt, use_bt, pack->size())) {
>> 263: VTransformNode* in = get_vtnode(pack_in->at(0));
>> 264: VTransformNode* cast = new (_vtransform.arena()) VTransformCastVectorNode(_vtransform, pack->size(), def_bt, use_bt);
>
> I just noticed: above, we already handle a cast case, but use `VTransformElementWiseVectorNode`:
> https://github.com/openjdk/jdk/pull/23413/files#diff-cd8469676c3f287680696b4dbd87fd02b765f2c9a249bd485c55613b15843435L213-L217
>
> I'm not happy with using `VTransformElementWiseVectorNode` for some casts and `VTransformCastVectorNode` for others. So I see 2 options:
> - Use `VTransformCastVectorNode` for both, refactor the code I linded.
> - Somehow try to remove `VTransformCastVectorNode`, and use `VTransformElementWiseVectorNode` here. Do you think that would be possible?
This is a great suggestion! I didn't realize we already had `VTransformElementWiseVectorNode` which works in this case when provided the vector opcode. That means `VTransformCastVectorNode` isn't needed, which reduces the size of the patch significantly.
> test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java line 65:
>
>> 63:
>> 64: @Test
>> 65: @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE_ANY, ">0" })
>
> I think you could get more precise vector size here as well, using `IRNode.VECTOR_SIZE + "min(max_int, max_short)"` as you did in the other test :)
Thanks for the heads up, I missed these when updating the tests!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23413#discussion_r2730046520
PR Review Comment: https://git.openjdk.org/jdk/pull/23413#discussion_r2730047128
More information about the hotspot-compiler-dev
mailing list