RFR: 8370863: VectorAPI: Optimize the VectorMaskCast chain in specific patterns [v8]

Eric Fang erfang at openjdk.org
Tue Jan 27 08:50:28 UTC 2026


On Tue, 27 Jan 2026 08:07:10 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Eric Fang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 12 commits:
>> 
>>  - Update copyright year to 2026
>>  - Merge branch 'master' into JDK-8370863-mask-cast-opt
>>  - Convert the check condition for vector length into an assertion
>>    
>>    Also refined the tests.
>>  - Refine code comments
>>  - Merge branch 'master' into JDK-8370863-mask-cast-opt
>>  - Merge branch 'master' into JDK-8370863-mask-cast-opt
>>  - Add MaxVectorSize IR test condition for VectorStoreMaskIdentityTest.java
>>  - Refine the test code and comments
>>  - Merge branch 'master' into JDK-8370863-mask-cast-opt
>>  - Don't read and write the same memory in the JMH benchmarks
>>  - ... and 2 more: https://git.openjdk.org/jdk/compare/6eaabed5...9c38a6d9
>
> src/hotspot/share/opto/vectornode.cpp line 1063:
> 
>> 1061:   return n;
>> 1062: }
>> 1063: 
> 
> This has a clear parallel in `Node::uncast`. But there, we may recursively uncast.
> 
> Your pattern:
> `(VectorStoreMask (VectorMaskCast* (VectorLoadMask x))) => (x)`
> 
> We could also have a chain of casts here.
> Can you explain why you chose only to do a single step here?

I'm not sure I fully understood your point. This function can recursively uncast a chain of consecutive `VectorMaskCastNode`, so the pattern you mentioned above can be optimized to `(x)` even when there are multiple `VectorMaskCastNode` in between.

I’m not sure I get what you mean. Could you elaborate on it a bit? Thanks~

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28313#discussion_r2730885339


More information about the hotspot-compiler-dev mailing list