On Mon, 15 Dec 2025 02:36:06 GMT, Eric Fang <[email protected]> wrote:

>> src/hotspot/share/opto/vectornode.cpp line 1492:
>> 
>>> 1490:   //   vector[n]{bool} => vector[n]{t} => vector[n]{bool}
>>> 1491:   Node* in1 = VectorNode::uncast_mask(in(1));
>>> 1492:   if (in1->Opcode() == Op_VectorLoadMask && length() == 
>>> in1->as_Vector()->length()) {
>> 
>> Can there be a mismatch with the length? Can you give me an example?
>
> There are currently no such counterexamples. Because now we require the 
> length of `VectorMaskCastNode` to be consistent with the length of its input 
> node. But I'm not sure whether this restriction will be lifted in the future, 
> and this optimization requires the length to be the same. Because of this 
> requirement, I added this check. Similarly, in `uncast_mask` I also did the 
> following assert:
> `assert(n->as_Vector()->length() == in1->as_Vector()->length(), "vector 
> length must match");`
> 
> Do you think it would be better to change this condition to an assert?

Yeah, currently we might not have such a real case that the length is not 
matched, regardless whether there is mask casts inside the chain. At least I 
cannot find such a case in API level.  Not sure whether such pattern will be 
generated by compiler itself in future due to some optimizations.

As an optimization of `VectorStoreMask (VectorLoadMask vect) => vec`, we must 
make sure that the vector type before and after are exactly matched with each 
other. Consider both the basic element type of `VectorStoreMask` and the input 
of `VectorLoadMask` (i.e. the `vect`) are `boolean`, just checking the vector 
length is enough.

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

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

Reply via email to