<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div>Hi Jakub,</div>
<div><br>
</div>
You should only need to use a constant species, the log output indicates it is not contrary to the code you show. Is your actual code different?
<div><br>
</div>
<div>The HotSpot code you link to requires that the vector/mask class, element class (etype), and vector length be constants, these all come from the species. So if the species is constant they will be. Strangely your log output indicates the element class
is constant but the vector/mask class and vector length are not.</div>
<div> </div>
<div>Paul.<br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On Oct 13, 2024, at 11:01 AM, Jakub Okoński <jakub@okonski.org> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div dir="ltr">
<div>Hi Rado,</div>
<div><br>
</div>
<div>That makes sense and making it static final did help inline these intrinsics in my benchmark, thank you.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Jakub<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, 13 Oct 2024 at 18:27, <<a href="mailto:rsmogura@icloud.com">rsmogura@icloud.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>Hi Kuba,
<div><br>
</div>
<div>I hope you are well.</div>
<div><br>
</div>
<div>Without code being seen it's hard to troubleshoot issue with 100% certainty.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Rado<br id="m_702525976696974240lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On 12 Oct 2024, at 23:25, Jakub Okoński <<a href="mailto:jakub@okonski.org" target="_blank">jakub@okonski.org</a>> wrote:</div>
<br>
<div>
<div dir="ltr">
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>I noticed that the following code doesn't get intrinsified:</div>
<div><br>
</div>
<div> VectorMask.fromLong(ByteVector.SPECIES_128, someInt)</div>
<div><br>
</div>
<div>Profiling with JFR reveals that this method falls back to fromArray and allocates a boolean[], which is undesirable.</div>
<div><br>
</div>
<div>It has to be this fallback code: <a href="https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java#L252" target="_blank">
https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java#L252</a></div>
<div><br>
</div>
<div>With PrintIntrin, I'm seeing this message<br>
<br>
** missing constant: vclass=DecodeN etype=ConP vlen=LoadI bitwise=ConI</div>
<div><br>
</div>
<div>I modified the logging and narrowed it down to vector_klass->const_oop() being a nullptr<br>
<br>
<a href="https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/hotspot/share/opto/vectorIntrinsics.cpp#L833" target="_blank">https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/hotspot/share/opto/vectorIntrinsics.cpp#L833</a></div>
<div><br>
</div>
<div>I then tried to cheat and hardcode the vector class and lane count in VectorMask.java so it knows the arguments statically, like so:</div>
<div><br>
</div>
<div> return VectorSupport.fromBitsCoerced((Class<? extends AbstractMask<E>>) (Class<?>) Byte128Vector.Byte128Mask.class, vsp.elementType(), 16, bits, ...<br>
<br>
</div>
<div>While this did make inlining happen (as reported by PrintIntrin at least), I couldn't get rid of the boolean[] allocations.</div>
<div><br>
</div>
<div>I'm testing on 41ee582df8c65f2f26b21e46784cf0bc4ece0585 amd64 Linux.<br>
</div>
<div><br>
</div>
<div>Regards,</div>
<div>Jakub<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>