Skip to content

Commit 08debd3

Browse files
committed
8346993: C2 SuperWord: refactor to make more vector nodes available in VectorNode::make
Reviewed-by: chagedorn, kvn
1 parent de02503 commit 08debd3

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

src/hotspot/share/opto/vectornode.cpp

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -666,7 +666,7 @@ VectorNode* VectorNode::make_mask_node(int vopc, Node* n1, Node* n2, uint vlen,
666666
}
667667
}
668668

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

750+
case Op_LShiftCntV: return new LShiftCntVNode(n1, vt);
751+
case Op_RShiftCntV: return new RShiftCntVNode(n1, vt);
752+
750753
case Op_AndV: return new AndVNode(n1, n2, vt);
751754
case Op_OrV: return new OrVNode (n1, n2, vt);
752755
case Op_XorV: return new XorVNode(n1, n2, vt);
@@ -766,6 +769,18 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, b
766769
case Op_SaturatingAddV: return new SaturatingAddVNode(n1, n2, vt, is_unsigned);
767770
case Op_SaturatingSubV: return new SaturatingSubVNode(n1, n2, vt, is_unsigned);
768771

772+
case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt);
773+
case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt);
774+
case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt);
775+
case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt);
776+
case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt);
777+
case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt);
778+
case Op_VectorUCastB2X: return new VectorUCastB2XNode(n1, vt);
779+
case Op_VectorUCastS2X: return new VectorUCastS2XNode(n1, vt);
780+
case Op_VectorUCastI2X: return new VectorUCastI2XNode(n1, vt);
781+
case Op_VectorCastHF2F: return new VectorCastHF2FNode(n1, vt);
782+
case Op_VectorCastF2HF: return new VectorCastF2HFNode(n1, vt);
783+
769784
default:
770785
fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
771786
return nullptr;
@@ -791,6 +806,7 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, Node* n3, const TypeV
791806
case Op_SelectFromTwoVector: return new SelectFromTwoVectorNode(n1, n2, n3, vt);
792807
case Op_SignumVD: return new SignumVDNode(n1, n2, n3, vt);
793808
case Op_SignumVF: return new SignumVFNode(n1, n2, n3, vt);
809+
case Op_VectorBlend: return new VectorBlendNode(n1, n2, n3);
794810
default:
795811
fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
796812
return nullptr;
@@ -818,22 +834,26 @@ VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, BasicType bt, bool is_
818834
}
819835

820836
VectorNode* VectorNode::shift_count(int opc, Node* cnt, uint vlen, BasicType bt) {
821-
// Match shift count type with shift vector type.
837+
int vopc = VectorNode::shift_count_opcode(opc);
822838
const TypeVect* vt = TypeVect::make(bt, vlen);
839+
return VectorNode::make(vopc, cnt, nullptr, vt);
840+
}
841+
842+
int VectorNode::shift_count_opcode(int opc) {
823843
switch (opc) {
824844
case Op_LShiftI:
825845
case Op_LShiftL:
826-
return new LShiftCntVNode(cnt, vt);
846+
return Op_LShiftCntV;
827847
case Op_RShiftI:
828848
case Op_RShiftL:
829849
case Op_URShiftB:
830850
case Op_URShiftS:
831851
case Op_URShiftI:
832852
case Op_URShiftL:
833-
return new RShiftCntVNode(cnt, vt);
853+
return Op_RShiftCntV;
834854
default:
835-
fatal("Missed vector creation for '%s'", NodeClassNames[opc]);
836-
return nullptr;
855+
fatal("Node class '%s' is not supported for shift count", NodeClassNames[opc]);
856+
return -1;
837857
}
838858
}
839859

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

1415-
VectorCastNode* VectorCastNode::make(int vopc, Node* n1, BasicType bt, uint vlen) {
1435+
VectorNode* VectorCastNode::make(int vopc, Node* n1, BasicType bt, uint vlen) {
14161436
const TypeVect* vt = TypeVect::make(bt, vlen);
1417-
switch (vopc) {
1418-
case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt);
1419-
case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt);
1420-
case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt);
1421-
case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt);
1422-
case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt);
1423-
case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt);
1424-
case Op_VectorUCastB2X: return new VectorUCastB2XNode(n1, vt);
1425-
case Op_VectorUCastS2X: return new VectorUCastS2XNode(n1, vt);
1426-
case Op_VectorUCastI2X: return new VectorUCastI2XNode(n1, vt);
1427-
case Op_VectorCastHF2F: return new VectorCastHF2FNode(n1, vt);
1428-
case Op_VectorCastF2HF: return new VectorCastF2HFNode(n1, vt);
1429-
default:
1430-
assert(false, "unknown node: %s", NodeClassNames[vopc]);
1431-
return nullptr;
1432-
}
1437+
return VectorNode::make(vopc, n1, nullptr, vt);
14331438
}
14341439

14351440
int VectorCastNode::opcode(int sopc, BasicType bt, bool is_signed) {

src/hotspot/share/opto/vectornode.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -95,6 +95,8 @@ class VectorNode : public TypeNode {
9595
static int opcode(int sopc, BasicType bt); // scalar_opc -> vector_opc
9696
static int scalar_opcode(int vopc, BasicType bt); // vector_opc -> scalar_opc
9797

98+
static int shift_count_opcode(int opc);
99+
98100
// Limits on vector size (number of elements) for auto-vectorization.
99101
static bool vector_size_supported_auto_vectorization(const BasicType bt, int size);
100102
static bool implemented(int opc, uint vlen, BasicType bt);
@@ -1764,7 +1766,7 @@ class VectorCastNode : public VectorNode {
17641766
VectorCastNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {}
17651767
virtual int Opcode() const;
17661768

1767-
static VectorCastNode* make(int vopc, Node* n1, BasicType bt, uint vlen);
1769+
static VectorNode* make(int vopc, Node* n1, BasicType bt, uint vlen);
17681770
static int opcode(int opc, BasicType bt, bool is_signed = true);
17691771
static bool implemented(int opc, uint vlen, BasicType src_type, BasicType dst_type);
17701772

0 commit comments

Comments
 (0)