RFR: 8291600: [vectorapi] vector cast op check is not always needed for vector mask cast [v5]

Jie Fu jiefu at openjdk.org
Wed Aug 31 03:59:15 UTC 2022


On Wed, 31 Aug 2022 03:08:33 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:

>> src/hotspot/share/opto/vectorIntrinsics.cpp line 2498:
>> 
>>> 2496:     }
>>> 2497:     if (is_mask && is_floating_point_type(elem_bt_to)) {
>>> 2498:       new_elem_bt_to = elem_bt_to == T_FLOAT ? T_INT : T_LONG;
>> 
>> Why we need this change?
>
> Before `VectorCast` is used for vector mask casting, the src floating point type has been casted to an integral type that has the same element size. Please see the codes here: https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/vectornode.cpp#L1741. We'd better to check the right type of the generated vector cast op.

OK, seems fine to me.
Thanks.

>> src/hotspot/share/opto/vectorIntrinsics.cpp line 2503:
>> 
>>> 2501: 
>>> 2502:     // Make sure that vector cast is implemented to particular type/size combination.
>>> 2503:     bool no_vec_cast_check = is_mask && (src_type->isa_vectmask() ||
>> 
>> To make it safer, let's also check `dst_type->isa_vectmask()` like the following.
>> 
>>       if (is_mask) {
>>         if ((dst_type->isa_vectmask() && src_type->isa_vectmask()) ||
>>             (type2aelembytes(elem_bt_from) == type2aelembytes(elem_bt_to))) {
>>           op = gvn().transform(new VectorMaskCastNode(op, dst_type));
>>         } else {
>>           op = VectorMaskCastNode::makeCastNode(&gvn(), op, dst_type);
>>         }
>>       }
>
> From the check https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/vectorIntrinsics.cpp#L2485, we know the basic mask type of dst and src must be the same. So just checking `src_type` is ok here. Besides, this part of changes will be removed finally after I unify the vector mask cast operation.

But the mismatch seems strange to me.

Maybe, you can 
1) Add `dst_type->isa_vectmask()` check here, or
2) Also delete `dst_type->isa_vectmask()`  (https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/vectorIntrinsics.cpp#L2551)

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

PR: https://git.openjdk.org/jdk/pull/9737


More information about the hotspot-compiler-dev mailing list