RFR: JDK-8308994: C2: Re-implement experimental post loop vectorization

Emanuel Peter epeter at openjdk.org
Fri Jun 23 11:38:10 UTC 2023


On Fri, 23 Jun 2023 11:33:05 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> src/hotspot/share/opto/vectornode.hpp line 1839:
>> 
>>> 1837:   virtual bool cmp(const Node& n) const {
>>> 1838:     return TypeNode::cmp(n) &&
>>> 1839:            _max_trips == ((LoopVectorMaskNode&)n)._max_trips;
>> 
>> Is this cast really safe? Can you use `as_LoopVectorMaskNode()` instead, so we at least have an assert if it fails to be true? I fear this may get us into undefined behavior otherwise...
>
> Oh dear, I just saw the same pattern in:
> 
> bool TypeNode::cmp(const Node& n) const {
>   return !Type::cmp(_type, ((TypeNode&)n)._type);
> }
> 
> We should try to avoid doing that.

Even if all callers currently ensure that `n` has the correct type, I'd say it is still not a great idea to cast without checking, at least in debug.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14581#discussion_r1239711766


More information about the hotspot-dev mailing list