Skip to content

Commit

Permalink
8346993: C2 SuperWord: refactor to make more vector nodes available i…
Browse files Browse the repository at this point in the history
…n VectorNode::make

Reviewed-by: chagedorn, kvn
  • Loading branch information
eme64 committed Jan 7, 2025
1 parent de02503 commit 08debd3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
53 changes: 29 additions & 24 deletions src/hotspot/share/opto/vectornode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -666,7 +666,7 @@ VectorNode* VectorNode::make_mask_node(int vopc, Node* n1, Node* n2, uint vlen,
}
}

// Make a vector node for binary operation
// Make a vector node for unary or binary operation
VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask, bool is_var_shift, bool is_unsigned) {
// This method should not be called for unimplemented vectors.
guarantee(vopc > 0, "vopc must be > 0");
Expand Down Expand Up @@ -747,6 +747,9 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, b
case Op_URShiftVI: return new URShiftVINode(n1, n2, vt, is_var_shift);
case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt, is_var_shift);

case Op_LShiftCntV: return new LShiftCntVNode(n1, vt);
case Op_RShiftCntV: return new RShiftCntVNode(n1, vt);

case Op_AndV: return new AndVNode(n1, n2, vt);
case Op_OrV: return new OrVNode (n1, n2, vt);
case Op_XorV: return new XorVNode(n1, n2, vt);
Expand All @@ -766,6 +769,18 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, b
case Op_SaturatingAddV: return new SaturatingAddVNode(n1, n2, vt, is_unsigned);
case Op_SaturatingSubV: return new SaturatingSubVNode(n1, n2, vt, is_unsigned);

case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt);
case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt);
case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt);
case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt);
case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt);
case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt);
case Op_VectorUCastB2X: return new VectorUCastB2XNode(n1, vt);
case Op_VectorUCastS2X: return new VectorUCastS2XNode(n1, vt);
case Op_VectorUCastI2X: return new VectorUCastI2XNode(n1, vt);
case Op_VectorCastHF2F: return new VectorCastHF2FNode(n1, vt);
case Op_VectorCastF2HF: return new VectorCastF2HFNode(n1, vt);

default:
fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
return nullptr;
Expand All @@ -791,6 +806,7 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, Node* n3, const TypeV
case Op_SelectFromTwoVector: return new SelectFromTwoVectorNode(n1, n2, n3, vt);
case Op_SignumVD: return new SignumVDNode(n1, n2, n3, vt);
case Op_SignumVF: return new SignumVFNode(n1, n2, n3, vt);
case Op_VectorBlend: return new VectorBlendNode(n1, n2, n3);
default:
fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
return nullptr;
Expand Down Expand Up @@ -818,22 +834,26 @@ VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, BasicType bt, bool is_
}

VectorNode* VectorNode::shift_count(int opc, Node* cnt, uint vlen, BasicType bt) {
// Match shift count type with shift vector type.
int vopc = VectorNode::shift_count_opcode(opc);
const TypeVect* vt = TypeVect::make(bt, vlen);
return VectorNode::make(vopc, cnt, nullptr, vt);
}

int VectorNode::shift_count_opcode(int opc) {
switch (opc) {
case Op_LShiftI:
case Op_LShiftL:
return new LShiftCntVNode(cnt, vt);
return Op_LShiftCntV;
case Op_RShiftI:
case Op_RShiftL:
case Op_URShiftB:
case Op_URShiftS:
case Op_URShiftI:
case Op_URShiftL:
return new RShiftCntVNode(cnt, vt);
return Op_RShiftCntV;
default:
fatal("Missed vector creation for '%s'", NodeClassNames[opc]);
return nullptr;
fatal("Node class '%s' is not supported for shift count", NodeClassNames[opc]);
return -1;
}
}

Expand Down Expand Up @@ -1412,24 +1432,9 @@ VectorStoreMaskNode* VectorStoreMaskNode::make(PhaseGVN& gvn, Node* in, BasicTyp
return new VectorStoreMaskNode(in, gvn.intcon(elem_size), vt);
}

VectorCastNode* VectorCastNode::make(int vopc, Node* n1, BasicType bt, uint vlen) {
VectorNode* VectorCastNode::make(int vopc, Node* n1, BasicType bt, uint vlen) {
const TypeVect* vt = TypeVect::make(bt, vlen);
switch (vopc) {
case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt);
case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt);
case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt);
case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt);
case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt);
case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt);
case Op_VectorUCastB2X: return new VectorUCastB2XNode(n1, vt);
case Op_VectorUCastS2X: return new VectorUCastS2XNode(n1, vt);
case Op_VectorUCastI2X: return new VectorUCastI2XNode(n1, vt);
case Op_VectorCastHF2F: return new VectorCastHF2FNode(n1, vt);
case Op_VectorCastF2HF: return new VectorCastF2HFNode(n1, vt);
default:
assert(false, "unknown node: %s", NodeClassNames[vopc]);
return nullptr;
}
return VectorNode::make(vopc, n1, nullptr, vt);
}

int VectorCastNode::opcode(int sopc, BasicType bt, bool is_signed) {
Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/opto/vectornode.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -95,6 +95,8 @@ class VectorNode : public TypeNode {
static int opcode(int sopc, BasicType bt); // scalar_opc -> vector_opc
static int scalar_opcode(int vopc, BasicType bt); // vector_opc -> scalar_opc

static int shift_count_opcode(int opc);

// Limits on vector size (number of elements) for auto-vectorization.
static bool vector_size_supported_auto_vectorization(const BasicType bt, int size);
static bool implemented(int opc, uint vlen, BasicType bt);
Expand Down Expand Up @@ -1764,7 +1766,7 @@ class VectorCastNode : public VectorNode {
VectorCastNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {}
virtual int Opcode() const;

static VectorCastNode* make(int vopc, Node* n1, BasicType bt, uint vlen);
static VectorNode* make(int vopc, Node* n1, BasicType bt, uint vlen);
static int opcode(int opc, BasicType bt, bool is_signed = true);
static bool implemented(int opc, uint vlen, BasicType src_type, BasicType dst_type);

Expand Down

0 comments on commit 08debd3

Please sign in to comment.