Vector API: VectorMask.fromLong is not intrinsified

rsmogura at icloud.com rsmogura at icloud.com
Sun Oct 13 16:27:36 UTC 2024


Hi Kuba,

I hope you are well.

Without code being seen it's hard to troubleshoot issue with 100% certainty.

However, I wonder if not being constant OOP can be cause that maks or someInt is not constant. it's preferred that vectors and mask will be declared as static final (which is considered const by VM), and than VM can apply more stronger optimisations.

Best regards,
Rado

> On 12 Oct 2024, at 23:25, Jakub Okoński <jakub at okonski.org> wrote:
> 
> Hi,
> 
> I noticed that the following code doesn't get intrinsified:
> 
>     VectorMask.fromLong(ByteVector.SPECIES_128, someInt)
> 
> Profiling with JFR reveals that this method falls back to fromArray and allocates a boolean[], which is undesirable.
> 
> It has to be this fallback code: https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java#L252
> 
> With PrintIntrin, I'm seeing this message
> 
> ** missing constant: vclass=DecodeN etype=ConP vlen=LoadI bitwise=ConI
> 
> I modified the logging and narrowed it down to vector_klass->const_oop() being a nullptr
> 
> https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/hotspot/share/opto/vectorIntrinsics.cpp#L833
> 
> I then tried to cheat and hardcode the vector class and lane count in VectorMask.java so it knows the arguments statically, like so:
> 
>         return VectorSupport.fromBitsCoerced((Class<? extends AbstractMask<E>>) (Class<?>) Byte128Vector.Byte128Mask.class, vsp.elementType(), 16, bits, ...
> 
> While this did make inlining happen (as reported by PrintIntrin at least), I couldn't get rid of the boolean[] allocations.
> 
> I'm testing on 41ee582df8c65f2f26b21e46784cf0bc4ece0585 amd64 Linux.
> 
> Regards,
> Jakub

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20241013/757fb7b1/attachment.htm>


More information about the panama-dev mailing list