[vectorIntrinsics+mask] RFR: 8266287: Basic mask IR implementation for the Vector API masking feature support

Xiaohong Gong xgong at openjdk.java.net
Thu May 13 02:19:26 UTC 2021


On Wed, 12 May 2021 10:50:30 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Based on [1], this patch adds the C2 compiler mid-end changes for the masking feature support. It mainly contains:
>>  1) Generation of the mask IRs for vector mask, including:
>>     - Mask generations, e.g. load/compare/maskAll
>>     - Mask operations, e.g. and/or/xor
>>  2) Conversions between vector and mask after loading mask values from memory and before storing mask values into memory
>>  3) Generation of the vector IRs which need the mask value as the control
>>     - The mask value is appended to the original vector node's input list
>> 
>> With this change, the bottom type of the vector mask will be set to `"TypeVectMask"` if the platform supports the masking feature and the backend implementations are added.
>> 
>> Note that this patch only contains the compiler mid-end changes. The backend implementations for SVE/AVX-512 will be in the
>> followed-up patches.
>> 
>> [1] https://github.com/openjdk/panama-vector/pull/57
>
> src/hotspot/share/opto/vectorIntrinsics.cpp line 84:
> 
>> 82:   assert(check_vbox(vbox_type), "");
>> 83:   const TypeVect* vt = is_vector_mask(vbox_type->klass()) ?
>> 84:                        TypeVect::makemask(elem_bt, num_elem) : TypeVect::make(elem_bt, num_elem);
> 
> Box type which is an envelope type should still be the same e.g. Int256VectorMask. Value contained in the Masked Box should be of type vectmask.

OK, I don't remember what exactly the issue I met for this part. But one reason of this change is to make it easy for the `VectorUnboxNode::Identity`, which could directly return the boxed value if the unbox type and the boxed value type is exactly matched:

Node* VectorUnboxNode::Identity(PhaseGVN* phase) {
  Node* n = obj()->uncast();
  if (EnableVectorReboxing && n->Opcode() == Op_VectorBox) {
    if (Type::cmp(bottom_type(), n->in(VectorBoxNode::Value)->bottom_type()) == 0) {
      return n->in(VectorBoxNode::Value); // VectorUnbox (VectorBox v) ==> v
    } else {
      // Handled by VectorUnboxNode::Ideal().
    }
  }
  return this;
}

Using `TypeVect` for `VectorBox/Unbox` while `TypeVectMask` for the boxed value will make the type mismatched. But I think it's not the main problem, we could add some logics to make them matched. @iwanowww do you have any ideas about this part? Thanks!

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

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


More information about the panama-dev mailing list