RFR: 8367292: VectorAPI: Optimize VectorMask.fromLong/toLong() for SVE [v3]

Xiaohong Gong xgong at openjdk.org
Tue Oct 28 10:23:06 UTC 2025


On Tue, 28 Oct 2025 08:17:07 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> The implementation on AArch64 would be like:
>> 
>> bool Matcher::mask_op_prefers_predicate(int opcode, const TypeVect* vt) {
>>     // Only SVE supports the predicate feature.
>>     if (UseSVE == 0) {
>>       // On architectures that do not support the predicate feature, vector
>>       // mask is stored in a normal vector with the type of "TypeVect" varing
>>       // from "TypeVectA" to "TypeVectZ" based on the vector length in bytes.
>>       // It cannot be a "TypeVectMask".
>>       assert(vt->isa_vectmask() == nullptr, "mask type not match");
>>       return false;
>>     }
>> 
>>     assert(vt->isa_vectmask(), "The mask type must be a TypeVectMask on SVE");
>>     switch (opcode) {
>>       case Op_VectorMaskToLong:
>>       case Op_VectorLongToMask:
>>         // SVE does not have native predicate instructions for these two ops.
>>         // Instead, they are implemented with vector instructions. Hence, to
>>         // improve the performance, we prefer saving the mask in a vector as
>>         // the input/output of these IRs.
>>         return false;
>>       default:
>>         // By default, all the mask operations are implemented with predicate
>>         // instructions with a predicate input/output.
>>         return true;
>>     }
>>   }
>> 
>> And the comments before the helper function in matcher.hpp:
>> 
>>   // Identify if a vector mask operation requires the input/output mask to be
>>   // saved with a predicate type (i.e. TypeVectMask) or not. Return true if it
>>   // requires a predicate type. And return false if it requires a vector type.
>>   static bool mask_op_prefers_predicate(int opcode, const TypeVect* vt);
>> 
>> 
>> Is that more clear? Thanks!
>
> Yes, these are a step int the right direction! :)
> 
> Thanks a lot for the explanations, very helpful! Please make sure that they are all represented in the code comments, so we don't lose them to this GitHub thread!
> 
> `// Identify if a vector mask operation requires the input/output mask to be`
> The language of `requires` slipped again into your explanation. Is that intended? Probably not?
> You should use a condensed version from your GitHub comments above, I think that would be very helpful :)

Current comment might be confusing. I will use `requires` both in comments and method name. Hope this would be more clear. WDYT?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27481#discussion_r2468909747


More information about the hotspot-compiler-dev mailing list