[vectorIntrinsics+mask] RFR: 8266287: Basic mask IR implementation for the Vector API masking feature support
Jatin Bhateja
jbhateja at openjdk.java.net
Wed May 12 10:40:21 UTC 2021
On Thu, 6 May 2021 10:12:08 GMT, Xiaohong Gong <xgong 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/adlc/formssel.cpp line 3888:
> 3886: if (_rChild)
> 3887: _rChild->count_commutative_op(count);
> 3888: }
Matcher rules based on proposed masked IR shall look like following
match(Set dst AddVI (Binary vsrc1 vsrc2) mask)
AddVI is still commutative and generated DFA will check for appropriate child states i.e.
kid[0]->state == _Binary_vec_vec && kid[1]->state == _mask
So even if matcher generates additional check by swapping the states of the two child nodes it should still be ok. Can you kindly elaborate the need for this change.
src/hotspot/share/opto/matcher.cpp line 2332:
> 2330: return;
> 2331: }
> 2332:
If we add a new flag for masked nodes, it may simplify the checking logic for masking operations. e.g.
node.hpp:
class Node {
// Flags are sorted by usage frequency.
enum NodeFlags {
Flag_is_Copy = 1 << 0, // should be first bit to avoid shift
Flag_rematerialize = 1 << 1,
Flag_needs_anti_dependence_check = 1 << 2,
Flag_is_macro = 1 << 3,
Flag_is_Con = 1 << 4,
Flag_is_cisc_alternate = 1 << 5,
Flag_is_dead_loop_safe = 1 << 6,
Flag_may_be_short_branch = 1 << 7,
Flag_avoid_back_to_back_before = 1 << 8,
Flag_avoid_back_to_back_after = 1 << 9,
Flag_has_call = 1 << 10,
Flag_is_reduction = 1 << 11,
Flag_is_scheduled = 1 << 12,
**Flag_has_vector_mask_set** = 1 << 13,
-------------
PR: https://git.openjdk.java.net/panama-vector/pull/78
More information about the panama-dev
mailing list