[vectorIntrinsics+mask] RFR: 8268154: Add masking support for vector load intrinsics

Jatin Bhateja jbhateja at openjdk.java.net
Wed Jun 9 12:11:26 UTC 2021


On Mon, 7 Jun 2021 09:05:44 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:

> This patch adds the predicate support for masked load vector operation, including the Vector API java implementation and hotspot intrinsics changes. The main changes contain:
>   - Adding a new hotspot intrinsic method (`loadMasked`), which can transform the vector mask class and value to hotspot. It is called by the masked `"fromArray"` API in JAVA level. The compiler will generate the masked vector load node if the current platform supports the predicate feature and backend has implemented it. Otherwise, the vector blend pattern will be generated like before.
>   - Adding the similar masked support for load/store boolean/char array.
> 
> Note that the intrinsification when there is the array range bailout is not implemented in this patch. We are considering making it vectorized with predicate feature for SVE/AVX-512 as well, and will create a separate patch for it in future.
> 
> Also note that this patch doesn't contain any backend changes.

Currently there following assertion check in both LoadVectorMaskedNode and StoreVectorMaskedNode  

`assert(mask->bottom_type()->is_vectmask(), "sanity");`

This should be relaxed since mask argument will be VectorUnboxNode until macro expansion.

I added following static routine in VectorNode class to get over it in my local sandbox, and adjusted the assertion to use it. If suitable maybe we can integrate it in this patch.


bool VectorNode::is_vector_mask(Node* n) {
  if (n->bottom_type()->is_vectmask()) {
    return true;
  }
  if (n->Opcode() == Op_VectorUnbox) {
    const TypeInstPtr* vector_klass_from = n->as_VectorUnbox()->obj()->bottom_type()->isa_instptr();
    ciKlass* vbox_klass_from = vector_klass_from->const_oop()->as_instance()->java_lang_Class_klass();
    return vbox_klass_from->is_subclass_of(ciEnv::current()->vector_VectorMask_klass());
  }
  return false;
}

Over all patch looks good to me.

src/hotspot/share/opto/vectorIntrinsics.cpp line 956:

> 954:   bool use_predicate = Matcher::has_predicated_vectors() &&
> 955:                        arch_supports_vector(sopc, num_elem, elem_bt, VecMaskUseLoad) &&
> 956:                        Matcher::match_rule_supported_vector_masked(sopc, num_elem, elem_bt);

Can we push both  Matcher::has_predicated_vectors() && Matcher::match_rule_supported_vector_masked() into arch_supports_vector and either add an explicit bool argument to it or a new enum value to be passed i.e. VecMaskUseLoad | VecPredOper  under which these checks are enforced.

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

PR: https://git.openjdk.java.net/panama-vector/pull/90


More information about the panama-dev mailing list