RFR: 8356760: VectorAPI: Optimize VectorMask.fromLong for all-true/all-false cases [v3]

erifan duke at openjdk.org
Thu Jul 24 03:41:54 UTC 2025


On Fri, 18 Jul 2025 03:14:58 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>>> > > > public static final VectorSpecies FSP = FloatVector.SPECIES_512;
>>> > > > public static long micro1(long a) {
>>> > > > long mask = Math.min(-1, Math.max(-1, a));
>>> > > > return VectorMask.fromLong(FSP, mask).toLong();
>>> > > > }
>>> > > > public static long micro2() {
>>> > > > return FSP.maskAll(true).toLong();
>>> > > > }
>>> > > 
>>> > > 
>>> > > With this JMH method we can not see obvious performance improvement, because the hot spots are other instructions. Adding a loop is better.
>>> > 
>>> > 
>>> > There is no hard and fast rule for the inclusion of a loop in a JMH micro in that case?
>>> 
>>> You mean adding a loop is not a block, right ?
>> 
>> Yes. If you see gains without loop go for it.
>
>> As @jatin-bhateja suggested, I have refactored the implementation and updated the commit message. please help review this PR, thanks!
> 
> Thanks a lot @erifan , I am out for the rest of the week, will re-review early next week.

@jatin-bhateja I have addressed your comments, would you mind take another look, thanks.

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

PR Comment: https://git.openjdk.org/jdk/pull/25793#issuecomment-3111848754


More information about the hotspot-compiler-dev mailing list