mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-09 01:48:34 +00:00
8283091: Support type conversion between different data sizes in SLP
Reviewed-by: kvn, sviswanathan
This commit is contained in:
parent
f7ba3b7e42
commit
a1795901ee
@ -2432,6 +2432,19 @@ const bool Matcher::match_rule_supported(int opcode) {
|
||||
return ret_value; // Per default match rules are supported.
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) {
|
||||
if (UseSVE == 0) {
|
||||
// ConvD2I and ConvL2F are not profitable to be vectorized on NEON, because no direct
|
||||
// NEON instructions support them. But the match rule support for them is profitable for
|
||||
// Vector API intrinsics.
|
||||
if ((opcode == Op_VectorCastD2X && bt == T_INT) ||
|
||||
(opcode == Op_VectorCastL2X && bt == T_FLOAT)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return match_rule_supported_vector(opcode, vlen, bt);
|
||||
}
|
||||
|
||||
// Identify extra cases that we might want to provide match rules for vector nodes and
|
||||
// other intrinsics guarded with vector length (vlen) and element type (bt).
|
||||
const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
|
||||
|
||||
@ -981,6 +981,10 @@ const bool Matcher::match_rule_supported(int opcode) {
|
||||
return true; // Per default match rules are supported.
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) {
|
||||
return match_rule_supported_vector(opcode, vlen, bt);
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
|
||||
|
||||
// TODO
|
||||
|
||||
@ -2165,6 +2165,10 @@ const bool Matcher::match_rule_supported(int opcode) {
|
||||
return true; // Per default match rules are supported.
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) {
|
||||
return match_rule_supported_vector(opcode, vlen, bt);
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
|
||||
if (!match_rule_supported(opcode) || !vector_size_supported(bt, vlen)) {
|
||||
return false;
|
||||
|
||||
@ -1815,6 +1815,10 @@ const bool Matcher::match_rule_supported(int opcode) {
|
||||
return true; // Per default match rules are supported.
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) {
|
||||
return match_rule_supported_vector(opcode, vlen, bt);
|
||||
}
|
||||
|
||||
// Identify extra cases that we might want to provide match rules for vector nodes and
|
||||
// other intrinsics guarded with vector length (vlen) and element type (bt).
|
||||
const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
|
||||
|
||||
@ -1505,6 +1505,10 @@ const bool Matcher::match_rule_supported(int opcode) {
|
||||
return true; // Per default match rules are supported.
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) {
|
||||
return match_rule_supported_vector(opcode, vlen, bt);
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
|
||||
if (!match_rule_supported(opcode) || !vector_size_supported(bt, vlen)) {
|
||||
return false;
|
||||
|
||||
@ -1693,6 +1693,10 @@ static inline bool is_pop_count_instr_target(BasicType bt) {
|
||||
(is_non_subword_integral_type(bt) && VM_Version::supports_avx512_vpopcntdq());
|
||||
}
|
||||
|
||||
const bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) {
|
||||
return match_rule_supported_vector(opcode, vlen, bt);
|
||||
}
|
||||
|
||||
// Identify extra cases that we might want to provide match rules for vector nodes and
|
||||
// other intrinsics guarded with vector length (vlen) and element type (bt).
|
||||
const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, 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
|
||||
@ -325,6 +325,10 @@ public:
|
||||
// should generate this one.
|
||||
static const bool match_rule_supported(int opcode);
|
||||
|
||||
// Identify extra cases that we might want to vectorize automatically
|
||||
// And exclude cases which are not profitable to auto-vectorize.
|
||||
static const bool match_rule_supported_superword(int opcode, int vlen, BasicType bt);
|
||||
|
||||
// identify extra cases that we might want to provide match rules for
|
||||
// e.g. Op_ vector nodes and other intrinsics while guarding with vlen
|
||||
static const bool match_rule_supported_vector(int opcode, int vlen, BasicType bt);
|
||||
|
||||
@ -374,8 +374,10 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Map the maximal common vector
|
||||
if (VectorNode::implemented(n->Opcode(), cur_max_vector, bt)) {
|
||||
// Map the maximal common vector except conversion nodes, because we can't get
|
||||
// the precise basic type for conversion nodes in the stage of early analysis.
|
||||
if (!VectorNode::is_convert_opcode(n->Opcode()) &&
|
||||
VectorNode::implemented(n->Opcode(), cur_max_vector, bt)) {
|
||||
if (cur_max_vector < max_vector && !flag_small_bt) {
|
||||
max_vector = cur_max_vector;
|
||||
} else if (cur_max_vector > max_vector && UseSubwordForMaxVector) {
|
||||
@ -1005,6 +1007,12 @@ int SuperWord::get_vw_bytes_special(MemNode* s) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for special case where there is a type conversion between different data size.
|
||||
int vectsize = max_vector_size_in_def_use_chain(s);
|
||||
if (vectsize < max_vector_size(btype)) {
|
||||
vw = MIN2(vectsize * type2aelembytes(btype), vw);
|
||||
}
|
||||
|
||||
return vw;
|
||||
}
|
||||
|
||||
@ -1193,7 +1201,9 @@ bool SuperWord::stmts_can_pack(Node* s1, Node* s2, int align) {
|
||||
BasicType bt2 = velt_basic_type(s2);
|
||||
if(!is_java_primitive(bt1) || !is_java_primitive(bt2))
|
||||
return false;
|
||||
if (Matcher::max_vector_size(bt1) < 2) {
|
||||
BasicType longer_bt = longer_type_for_conversion(s1);
|
||||
if (max_vector_size(bt1) < 2 ||
|
||||
(longer_bt != T_ILLEGAL && max_vector_size(longer_bt) < 2)) {
|
||||
return false; // No vectors for this type
|
||||
}
|
||||
|
||||
@ -1436,6 +1446,16 @@ void SuperWord::extend_packlist() {
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------adjust_alignment_for_type_conversion---------------------------------
|
||||
// Adjust the target alignment if conversion between different data size exists in def-use nodes.
|
||||
int SuperWord::adjust_alignment_for_type_conversion(Node* s, Node* t, int align) {
|
||||
if (longer_type_for_conversion(s) != T_ILLEGAL ||
|
||||
longer_type_for_conversion(t) != T_ILLEGAL) {
|
||||
align = align / data_size(s) * data_size(t);
|
||||
}
|
||||
return align;
|
||||
}
|
||||
|
||||
//------------------------------follow_use_defs---------------------------
|
||||
// Extend the packset by visiting operand definitions of nodes in pack p
|
||||
bool SuperWord::follow_use_defs(Node_List* p) {
|
||||
@ -1447,16 +1467,17 @@ bool SuperWord::follow_use_defs(Node_List* p) {
|
||||
|
||||
if (s1->is_Load()) return false;
|
||||
|
||||
int align = alignment(s1);
|
||||
NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SuperWord::follow_use_defs: s1 %d, align %d", s1->_idx, align);)
|
||||
NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SuperWord::follow_use_defs: s1 %d, align %d", s1->_idx, alignment(s1));)
|
||||
bool changed = false;
|
||||
int start = s1->is_Store() ? MemNode::ValueIn : 1;
|
||||
int end = s1->is_Store() ? MemNode::ValueIn+1 : s1->req();
|
||||
for (int j = start; j < end; j++) {
|
||||
int align = alignment(s1);
|
||||
Node* t1 = s1->in(j);
|
||||
Node* t2 = s2->in(j);
|
||||
if (!in_bb(t1) || !in_bb(t2))
|
||||
continue;
|
||||
align = adjust_alignment_for_type_conversion(s1, t1, align);
|
||||
if (stmts_can_pack(t1, t2, align)) {
|
||||
if (est_savings(t1, t2) >= 0) {
|
||||
Node_List* pair = new Node_List();
|
||||
@ -1500,12 +1521,15 @@ bool SuperWord::follow_def_uses(Node_List* p) {
|
||||
if (t2->Opcode() == Op_AddI && t2 == _lp->as_CountedLoop()->incr()) continue; // don't mess with the iv
|
||||
if (!opnd_positions_match(s1, t1, s2, t2))
|
||||
continue;
|
||||
if (stmts_can_pack(t1, t2, align)) {
|
||||
int adjusted_align = alignment(s1);
|
||||
adjusted_align = adjust_alignment_for_type_conversion(s1, t1, adjusted_align);
|
||||
if (stmts_can_pack(t1, t2, adjusted_align)) {
|
||||
int my_savings = est_savings(t1, t2);
|
||||
if (my_savings > savings) {
|
||||
savings = my_savings;
|
||||
u1 = t1;
|
||||
u2 = t2;
|
||||
align = adjusted_align;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1698,8 +1722,7 @@ void SuperWord::combine_packs() {
|
||||
for (int i = 0; i < _packset.length(); i++) {
|
||||
Node_List* p1 = _packset.at(i);
|
||||
if (p1 != NULL) {
|
||||
BasicType bt = velt_basic_type(p1->at(0));
|
||||
uint max_vlen = max_vector_size(bt); // Max elements in vector
|
||||
uint max_vlen = max_vector_size_in_def_use_chain(p1->at(0)); // Max elements in vector
|
||||
assert(is_power_of_2(max_vlen), "sanity");
|
||||
uint psize = p1->size();
|
||||
if (!is_power_of_2(psize)) {
|
||||
@ -2022,6 +2045,8 @@ bool SuperWord::implemented(Node_List* p) {
|
||||
} else {
|
||||
retValue = ReductionNode::implemented(opc, size, arith_type->basic_type());
|
||||
}
|
||||
} else if (VectorNode::is_convert_opcode(opc)) {
|
||||
retValue = VectorCastNode::implemented(opc, size, velt_basic_type(p0->in(1)), velt_basic_type(p0));
|
||||
} else {
|
||||
// Vector unsigned right shift for signed subword types behaves differently
|
||||
// from Java Spec. But when the shift amount is a constant not greater than
|
||||
@ -2616,12 +2641,11 @@ bool SuperWord::output() {
|
||||
Node* in = vector_opd(p, 1);
|
||||
vn = VectorNode::make(opc, in, NULL, vlen, velt_basic_type(n));
|
||||
vlen_in_bytes = vn->as_Vector()->length_in_bytes();
|
||||
} else if (opc == Op_ConvI2F || opc == Op_ConvL2D ||
|
||||
opc == Op_ConvF2I || opc == Op_ConvD2L) {
|
||||
} else if (VectorNode::is_convert_opcode(opc)) {
|
||||
assert(n->req() == 2, "only one input expected");
|
||||
BasicType bt = velt_basic_type(n);
|
||||
int vopc = VectorNode::opcode(opc, bt);
|
||||
Node* in = vector_opd(p, 1);
|
||||
int vopc = VectorCastNode::opcode(in->bottom_type()->is_vect()->element_basic_type());
|
||||
vn = VectorCastNode::make(vopc, in, bt, vlen);
|
||||
vlen_in_bytes = vn->as_Vector()->length_in_bytes();
|
||||
} else if (is_cmov_pack(p)) {
|
||||
@ -3134,9 +3158,26 @@ bool SuperWord::is_vector_use(Node* use, int u_idx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (u_pk->size() != d_pk->size())
|
||||
return false;
|
||||
|
||||
if (longer_type_for_conversion(use) != T_ILLEGAL) {
|
||||
// type conversion takes a type of a kind of size and produces a type of
|
||||
// another size - hence the special checks on alignment and size.
|
||||
for (uint i = 0; i < u_pk->size(); i++) {
|
||||
Node* ui = u_pk->at(i);
|
||||
Node* di = d_pk->at(i);
|
||||
if (ui->in(u_idx) != di) {
|
||||
return false;
|
||||
}
|
||||
if (alignment(ui) / type2aelembytes(velt_basic_type(ui)) !=
|
||||
alignment(di) / type2aelembytes(velt_basic_type(di))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint i = 0; i < u_pk->size(); i++) {
|
||||
Node* ui = u_pk->at(i);
|
||||
Node* di = d_pk->at(i);
|
||||
@ -3369,6 +3410,63 @@ void SuperWord::compute_max_depth() {
|
||||
}
|
||||
}
|
||||
|
||||
BasicType SuperWord::longer_type_for_conversion(Node* n) {
|
||||
int opcode = n->Opcode();
|
||||
switch (opcode) {
|
||||
case Op_ConvD2I:
|
||||
case Op_ConvI2D:
|
||||
case Op_ConvF2D:
|
||||
case Op_ConvD2F: return T_DOUBLE;
|
||||
case Op_ConvF2L:
|
||||
case Op_ConvL2F:
|
||||
case Op_ConvL2I:
|
||||
case Op_ConvI2L: return T_LONG;
|
||||
case Op_ConvI2F: {
|
||||
BasicType src_t = velt_basic_type(n->in(1));
|
||||
if (src_t == T_BYTE || src_t == T_SHORT) {
|
||||
return T_FLOAT;
|
||||
}
|
||||
return T_ILLEGAL;
|
||||
}
|
||||
case Op_ConvF2I: {
|
||||
BasicType dst_t = velt_basic_type(n);
|
||||
if (dst_t == T_BYTE || dst_t == T_SHORT) {
|
||||
return T_FLOAT;
|
||||
}
|
||||
return T_ILLEGAL;
|
||||
}
|
||||
}
|
||||
return T_ILLEGAL;
|
||||
}
|
||||
|
||||
int SuperWord::max_vector_size_in_def_use_chain(Node* n) {
|
||||
BasicType bt = velt_basic_type(n);
|
||||
BasicType vt = bt;
|
||||
|
||||
// find the longest type among def nodes.
|
||||
uint start, end;
|
||||
VectorNode::vector_operands(n, &start, &end);
|
||||
for (uint i = start; i < end; ++i) {
|
||||
Node* input = n->in(i);
|
||||
if (!in_bb(input)) continue;
|
||||
BasicType newt = longer_type_for_conversion(input);
|
||||
vt = (newt == T_ILLEGAL) ? vt : newt;
|
||||
}
|
||||
|
||||
// find the longest type among use nodes.
|
||||
for (uint i = 0; i < n->outcnt(); ++i) {
|
||||
Node* output = n->raw_out(i);
|
||||
if (!in_bb(output)) continue;
|
||||
BasicType newt = longer_type_for_conversion(output);
|
||||
vt = (newt == T_ILLEGAL) ? vt : newt;
|
||||
}
|
||||
|
||||
int max = max_vector_size(vt);
|
||||
// If now there is no vectors for the longest type, the nodes with the longest
|
||||
// type in the def-use chain are not packed in SuperWord::stmts_can_pack.
|
||||
return max < 2 ? max_vector_size(bt) : max;
|
||||
}
|
||||
|
||||
//-------------------------compute_vector_element_type-----------------------
|
||||
// Compute necessary vector element type for expressions
|
||||
// This propagates backwards a narrower integer type when the
|
||||
|
||||
@ -518,6 +518,7 @@ class SuperWord : public ResourceObj {
|
||||
int data_size(Node* s);
|
||||
// Extend packset by following use->def and def->use links from pack members.
|
||||
void extend_packlist();
|
||||
int adjust_alignment_for_type_conversion(Node* s, Node* t, int align);
|
||||
// Extend the packset by visiting operand definitions of nodes in pack p
|
||||
bool follow_use_defs(Node_List* p);
|
||||
// Extend the packset by visiting uses of nodes in pack p
|
||||
@ -571,6 +572,10 @@ class SuperWord : public ResourceObj {
|
||||
void bb_insert_after(Node* n, int pos);
|
||||
// Compute max depth for expressions from beginning of block
|
||||
void compute_max_depth();
|
||||
// Return the longer type for type-conversion node and return illegal type for other nodes.
|
||||
BasicType longer_type_for_conversion(Node* n);
|
||||
// Find the longest type in def-use chain for packed nodes, and then compute the max vector size.
|
||||
int max_vector_size_in_def_use_chain(Node* n);
|
||||
// Compute necessary vector element type for expressions
|
||||
void compute_vector_element_type();
|
||||
// Are s1 and s2 in a pack pair and ordered as s1,s2?
|
||||
|
||||
@ -248,14 +248,6 @@ int VectorNode::opcode(int sopc, BasicType bt) {
|
||||
return Op_StoreVector;
|
||||
case Op_MulAddS2I:
|
||||
return Op_MulAddVS2VI;
|
||||
case Op_ConvI2F:
|
||||
return Op_VectorCastI2X;
|
||||
case Op_ConvL2D:
|
||||
return Op_VectorCastL2X;
|
||||
case Op_ConvF2I:
|
||||
return Op_VectorCastF2X;
|
||||
case Op_ConvD2L:
|
||||
return Op_VectorCastD2X;
|
||||
case Op_CountLeadingZerosI:
|
||||
case Op_CountLeadingZerosL:
|
||||
return Op_CountLeadingZerosV;
|
||||
@ -268,6 +260,9 @@ int VectorNode::opcode(int sopc, BasicType bt) {
|
||||
return Op_SignumVD;
|
||||
|
||||
default:
|
||||
assert(!VectorNode::is_convert_opcode(sopc),
|
||||
"Convert node %s should be processed by VectorCastNode::opcode()",
|
||||
NodeClassNames[sopc]);
|
||||
return 0; // Unimplemented
|
||||
}
|
||||
}
|
||||
@ -315,7 +310,7 @@ bool VectorNode::implemented(int opc, uint vlen, BasicType bt) {
|
||||
if (VectorNode::is_vector_integral_negate(vopc)) {
|
||||
return is_vector_integral_negate_supported(vopc, vlen, bt, false);
|
||||
}
|
||||
return vopc > 0 && Matcher::match_rule_supported_vector(vopc, vlen, bt);
|
||||
return vopc > 0 && Matcher::match_rule_supported_superword(vopc, vlen, bt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -460,6 +455,26 @@ bool VectorNode::can_transform_shift_op(Node* n, BasicType bt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VectorNode::is_convert_opcode(int opc) {
|
||||
switch (opc) {
|
||||
case Op_ConvI2F:
|
||||
case Op_ConvL2D:
|
||||
case Op_ConvF2I:
|
||||
case Op_ConvD2L:
|
||||
case Op_ConvI2D:
|
||||
case Op_ConvL2F:
|
||||
case Op_ConvL2I:
|
||||
case Op_ConvI2L:
|
||||
case Op_ConvF2L:
|
||||
case Op_ConvD2F:
|
||||
case Op_ConvF2D:
|
||||
case Op_ConvD2I:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool VectorNode::is_shift(Node* n) {
|
||||
return is_shift_opcode(n->Opcode());
|
||||
}
|
||||
@ -1232,11 +1247,21 @@ int VectorCastNode::opcode(BasicType bt, bool is_signed) {
|
||||
case T_FLOAT: return Op_VectorCastF2X;
|
||||
case T_DOUBLE: return Op_VectorCastD2X;
|
||||
default:
|
||||
assert(false, "unknown type: %s", type2name(bt));
|
||||
assert(bt == T_CHAR || bt == T_BOOLEAN, "unknown type: %s", type2name(bt));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool VectorCastNode::implemented(int opc, uint vlen, BasicType src_type, BasicType dst_type) {
|
||||
if (is_java_primitive(dst_type) &&
|
||||
(vlen > 1) && is_power_of_2(vlen) &&
|
||||
VectorNode::vector_size_supported(dst_type, vlen)) {
|
||||
int vopc = VectorCastNode::opcode(src_type);
|
||||
return vopc > 0 && Matcher::match_rule_supported_superword(vopc, vlen, dst_type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Node* VectorCastNode::Identity(PhaseGVN* phase) {
|
||||
if (!in(1)->is_top()) {
|
||||
BasicType in_bt = in(1)->bottom_type()->is_vect()->element_basic_type();
|
||||
@ -1326,7 +1351,7 @@ bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
|
||||
(vlen > 1) && is_power_of_2(vlen) &&
|
||||
VectorNode::vector_size_supported(bt, vlen)) {
|
||||
int vopc = ReductionNode::opcode(opc, bt);
|
||||
return vopc != opc && Matcher::match_rule_supported_vector(vopc, vlen, bt);
|
||||
return vopc != opc && Matcher::match_rule_supported_superword(vopc, vlen, bt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ class VectorNode : public TypeNode {
|
||||
|
||||
static bool is_shift_opcode(int opc);
|
||||
static bool can_transform_shift_op(Node* n, BasicType bt);
|
||||
static bool is_convert_opcode(int opc);
|
||||
|
||||
static bool is_vshift_cnt_opcode(int opc);
|
||||
|
||||
@ -1520,7 +1521,7 @@ class VectorCastNode : public VectorNode {
|
||||
|
||||
static VectorCastNode* make(int vopc, Node* n1, BasicType bt, uint vlen);
|
||||
static int opcode(BasicType bt, bool is_signed = true);
|
||||
static bool implemented(BasicType bt, uint vlen);
|
||||
static bool implemented(int opc, uint vlen, BasicType src_type, BasicType dst_type);
|
||||
|
||||
virtual Node* Identity(PhaseGVN* phase);
|
||||
};
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package compiler.c2.irTests;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Asserts;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8283091
|
||||
* @summary Auto-vectorization enhancement for type conversion between different data sizes.
|
||||
* @requires (os.simpleArch == "x64" & vm.cpu.features ~= ".*avx2.*") | os.arch=="aarch64"
|
||||
* @library /test/lib /
|
||||
* @run driver compiler.c2.irTests.TestVectorizeTypeConversion
|
||||
*/
|
||||
|
||||
public class TestVectorizeTypeConversion {
|
||||
|
||||
final private static int SIZE = 3000;
|
||||
|
||||
private static double[] doublea = new double[SIZE];
|
||||
private static double[] doubleb = new double[SIZE];
|
||||
private static long[] longa = new long[SIZE];
|
||||
private static long[] longb = new long[SIZE];
|
||||
private static int[] inta = new int[SIZE];
|
||||
private static int[] intb = new int[SIZE];
|
||||
private static float[] floata = new float[SIZE];
|
||||
private static float[] floatb = new float[SIZE];
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestFramework.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
|
||||
IRNode.VECTOR_CAST_I2X, ">0",
|
||||
IRNode.STORE_VECTOR, ">0"})
|
||||
private static void testConvI2D(double[] d, int[] a) {
|
||||
for(int i = 0; i < d.length; i++) {
|
||||
d[i] = (double) (a[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
|
||||
IRNode.VECTOR_CAST_I2X, ">0",
|
||||
IRNode.VECTOR_CAST_L2X, ">0",
|
||||
IRNode.STORE_VECTOR, ">0"})
|
||||
private static void testConvI2L(int[] d1, int d2[], long[] a1, long[] a2) {
|
||||
for(int i = 0; i < d1.length; i++) {
|
||||
d1[i] = (int) (a1[i]);
|
||||
a2[i] = (long) (d2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
|
||||
IRNode.VECTOR_CAST_D2X, ">0",
|
||||
IRNode.VECTOR_CAST_F2X, ">0",
|
||||
IRNode.STORE_VECTOR, ">0"})
|
||||
private static void testConvF2D(double[] d1, double[] d2, float[] a1, float[] a2) {
|
||||
for(int i = 0; i < d1.length; i++) {
|
||||
d1[i] = (double) (a1[i]);
|
||||
a2[i] = (float) (d2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Run(test = {"testConvI2D", "testConvI2L", "testConvF2D"})
|
||||
private void test_runner() {
|
||||
testConvI2D(doublea, inta);
|
||||
testConvI2L(inta, intb, longa, longb);
|
||||
testConvF2D(doublea, doubleb, floata, floatb);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestByteDoubleVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestByteDoubleVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,32 @@ public class TestByteDoubleVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static final byte[] bspecial = {
|
||||
0, 0x8, 0xF, 0x3F, 0x7C, 0x7F, (byte)0x80, (byte)0x81, (byte)0x8F,
|
||||
(byte)0xF3, (byte)0xF8, (byte)0xFF, (byte)0x38FF, (byte)0x3FFF,
|
||||
(byte)0xFFFF, (byte)Integer.MAX_VALUE, (byte)Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static final double[] dspecial = {
|
||||
0.0,
|
||||
-0.0,
|
||||
Double.MAX_VALUE,
|
||||
Double.MIN_VALUE,
|
||||
-Double.MAX_VALUE,
|
||||
-Double.MIN_VALUE,
|
||||
Double.NaN,
|
||||
Double.POSITIVE_INFINITY,
|
||||
Double.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
-Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Byte + Double vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +105,8 @@ public class TestByteDoubleVect {
|
||||
test_vi_unaln(a1, b1, (byte)123, 103.);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_b2d(a1, b1);
|
||||
test_conv_d2b(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +370,41 @@ public class TestByteDoubleVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (byte)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (double)v);
|
||||
}
|
||||
for (int j = 0; j < bspecial.length; j++) {
|
||||
byte bytevalue = bspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = bytevalue;
|
||||
}
|
||||
test_conv_b2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_b2d: b1", i, b1[i], (double)bytevalue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < dspecial.length; j++) {
|
||||
double doubleValue = dspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = doubleValue;
|
||||
}
|
||||
test_conv_d2b(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2b: a1", i, a1[i], (byte)(doubleValue));
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = (byte)r.nextInt();
|
||||
}
|
||||
test_conv_b2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_b2d: b1", i, b1[i], (double)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextDouble();
|
||||
}
|
||||
test_conv_d2b(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2b: a1", i, a1[i], (byte)b1[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +515,18 @@ public class TestByteDoubleVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_b2d(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_b2d: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_d2b(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_d2b: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -557,6 +636,18 @@ public class TestByteDoubleVect {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_b2d(byte[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (double) a[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_d2b(byte[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (byte) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, byte elem, byte val) {
|
||||
if (elem != val) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestByteFloatVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestByteFloatVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,32 @@ public class TestByteFloatVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static final byte[] bspecial = {
|
||||
0, 0x8, 0xF, 0x3F, 0x7C, 0x7F, (byte)0x80, (byte)0x81, (byte)0x8F,
|
||||
(byte)0xF3, (byte)0xF8, (byte)0xFF, (byte)0x38FF, (byte)0x3FFF,
|
||||
(byte)0xFFFF, (byte)Integer.MAX_VALUE, (byte)Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static final float[] fspecial = {
|
||||
0.0f,
|
||||
-0.0f,
|
||||
Float.MAX_VALUE,
|
||||
Float.MIN_VALUE,
|
||||
-Float.MAX_VALUE,
|
||||
-Float.MIN_VALUE,
|
||||
Float.NaN,
|
||||
Float.POSITIVE_INFINITY,
|
||||
Float.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
-Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Byte + Float vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +105,8 @@ public class TestByteFloatVect {
|
||||
test_vi_unaln(a1, b1, (byte)123, 103.f);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_b2f(a1, b1);
|
||||
test_conv_f2b(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +370,41 @@ public class TestByteFloatVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (byte)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (float)v);
|
||||
}
|
||||
for (int j = 0; j < bspecial.length; j++) {
|
||||
byte byteValue = bspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = byteValue;
|
||||
}
|
||||
test_conv_b2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_b2f: b1", i, b1[i], (float)(byteValue));
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < fspecial.length; j++) {
|
||||
float floatValue = fspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = floatValue;
|
||||
}
|
||||
test_conv_f2b(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2b: a1", i, a1[i], (byte)floatValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = (byte)r.nextInt();
|
||||
}
|
||||
test_conv_b2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_b2f: b1", i, b1[i], (float)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextFloat();
|
||||
}
|
||||
test_conv_f2b(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2b: a1", i, a1[i], (byte)b1[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +515,18 @@ public class TestByteFloatVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_b2f(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_b2f: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_f2b(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_f2b: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -557,6 +636,18 @@ public class TestByteFloatVect {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_b2f(byte[] a, float[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (float) a[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_f2b(byte[] a, float[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (byte) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, byte elem, byte val) {
|
||||
if (elem != val) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestByteLongVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestByteLongVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,24 @@ public class TestByteLongVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static final byte[] bspecial = {
|
||||
0, 0x8, 0xF, 0x3F, 0x7C, 0x7F, (byte)0x80, (byte)0x81, (byte)0x8F,
|
||||
(byte)0xF3, (byte)0xF8, (byte)0xFF, (byte)0x38FF, (byte)0x3FFF,
|
||||
(byte)0xFFFF, (byte)Integer.MAX_VALUE, (byte)Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static final long[] lspecial = {
|
||||
0,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE,
|
||||
-Long.MIN_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Byte + Long vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +97,8 @@ public class TestByteLongVect {
|
||||
test_vi_unaln(a1, b1, (byte)123, (long)103);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_b2l(a1, b1);
|
||||
test_conv_l2b(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +362,41 @@ public class TestByteLongVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (byte)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (long)v);
|
||||
}
|
||||
for (int j = 0; j < bspecial.length; j++) {
|
||||
byte bytevalue = bspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = bytevalue;
|
||||
}
|
||||
test_conv_b2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_b2l: b1", i, b1[i], (long)bytevalue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < lspecial.length; j++) {
|
||||
long longValue = lspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = longValue;
|
||||
}
|
||||
test_conv_l2b(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2b: a1", i, a1[i], (byte)longValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = (byte)r.nextInt();
|
||||
}
|
||||
test_conv_b2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_b2l: b1", i, b1[i], (long)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextLong();
|
||||
}
|
||||
test_conv_l2b(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2b: a1", i, a1[i], (byte)b1[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +507,18 @@ public class TestByteLongVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_b2l(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_b2l: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_l2b(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_l2b: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -557,6 +628,18 @@ public class TestByteLongVect {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_b2l(byte[] a, long[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (long) a[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_l2b(byte[] a, long[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (byte) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, byte elem, byte val) {
|
||||
if (elem != val) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestFloatDoubleVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestFloatDoubleVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,46 @@ public class TestFloatDoubleVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static float[] fspecial = {
|
||||
0.0f,
|
||||
-0.0f,
|
||||
Float.MAX_VALUE,
|
||||
Float.MIN_VALUE,
|
||||
-Float.MAX_VALUE,
|
||||
-Float.MIN_VALUE,
|
||||
Float.NaN,
|
||||
Float.POSITIVE_INFINITY,
|
||||
Float.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
-Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE
|
||||
};
|
||||
|
||||
private static double[] dspecial = {
|
||||
0.0,
|
||||
-0.0,
|
||||
Double.MAX_VALUE,
|
||||
Double.MIN_VALUE,
|
||||
-Double.MAX_VALUE,
|
||||
-Double.MIN_VALUE,
|
||||
Double.NaN,
|
||||
Double.POSITIVE_INFINITY,
|
||||
Double.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
-Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Float + Double vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +119,8 @@ public class TestFloatDoubleVect {
|
||||
test_vi_unaln(a1, b1, 123.f, 103.);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_f2d(a1, b1);
|
||||
test_conv_d2f(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +384,41 @@ public class TestFloatDoubleVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (float)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (double)v);
|
||||
}
|
||||
for (int j = 0; j < fspecial.length; j++) {
|
||||
float floatValue = fspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = floatValue;
|
||||
}
|
||||
test_conv_f2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2d: b1", i, b1[i], (double)floatValue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < dspecial.length; j++) {
|
||||
double doubleValue = dspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = doubleValue;
|
||||
}
|
||||
test_conv_d2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2f: a1", i, a1[i], (float)(doubleValue));
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = r.nextFloat();
|
||||
}
|
||||
test_conv_f2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2d: b1", i, b1[i], (double)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextDouble();
|
||||
}
|
||||
test_conv_d2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2f: a1", i, a1[i], (float)b1[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +529,18 @@ public class TestFloatDoubleVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_f2d(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_f2d: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_d2f(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_d2f: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -557,15 +650,27 @@ public class TestFloatDoubleVect {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_f2d(float[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
b[i] = (double) a[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_d2f(float[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = (float) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, float elem, float val) {
|
||||
if (elem != val) {
|
||||
if (elem != val && !(Float.isNaN(elem) && Float.isNaN(val))) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int verify(String text, int i, double elem, double val) {
|
||||
if (elem != val) {
|
||||
if (elem != val && !(Double.isNaN(elem) && Double.isNaN(val))) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestIntDoubleVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestIntDoubleVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,36 @@ public class TestIntDoubleVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static double[] dspecial = {
|
||||
1.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
-0.0,
|
||||
Double.MAX_VALUE,
|
||||
Double.MIN_VALUE,
|
||||
-Double.MAX_VALUE,
|
||||
-Double.MIN_VALUE,
|
||||
Double.NaN,
|
||||
Double.POSITIVE_INFINITY,
|
||||
Double.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
-Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE
|
||||
};
|
||||
|
||||
private static int[] ispecial = {
|
||||
0,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Integer + Double vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +109,8 @@ public class TestIntDoubleVect {
|
||||
test_vi_unaln(a1, b1, (int)123, 103.);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_i2d(a1, b1);
|
||||
test_conv_d2i(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,7 +374,41 @@ public class TestIntDoubleVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (int)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (double)v);
|
||||
}
|
||||
|
||||
for (int j = 0; j < ispecial.length; j++) {
|
||||
int intValue = ispecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = intValue;
|
||||
}
|
||||
test_conv_i2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_i2d: b1", i, b1[i], (double)intValue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < dspecial.length; j++) {
|
||||
double doubleValue = dspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = doubleValue;
|
||||
}
|
||||
test_conv_d2i(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2i: a1", i, a1[i], (int)doubleValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = r.nextInt();
|
||||
}
|
||||
test_conv_i2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_i2d: b1", i, b1[i], (double)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextDouble();
|
||||
}
|
||||
test_conv_d2i(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2i: a1", i, a1[i], (int)b1[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (errn > 0)
|
||||
@ -448,6 +518,18 @@ public class TestIntDoubleVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_i2d(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_i2d: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_d2i(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_d2i: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -556,6 +638,16 @@ public class TestIntDoubleVect {
|
||||
c[i] = d[i+UNALIGN_OFF];
|
||||
}
|
||||
}
|
||||
static void test_conv_i2d(int[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (double) a[i];
|
||||
}
|
||||
}
|
||||
static void test_conv_d2i(int[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (int)b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, int elem, int val) {
|
||||
if (elem != val) {
|
||||
@ -565,7 +657,7 @@ public class TestIntDoubleVect {
|
||||
return 0;
|
||||
}
|
||||
static int verify(String text, int i, double elem, double val) {
|
||||
if (elem != val) {
|
||||
if (elem != val && !(Double.isNaN(elem) && Double.isNaN(val))) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestIntLongVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestIntLongVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,26 @@ public class TestIntLongVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static int[] ispecial = {
|
||||
0,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static long[] lspecial = {
|
||||
0,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE,
|
||||
-Long.MIN_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Integer + Long vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +99,8 @@ public class TestIntLongVect {
|
||||
test_vi_unaln(a1, b1, (int)123, (long)103);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_i2l(a1, b1);
|
||||
test_conv_l2i(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +364,41 @@ public class TestIntLongVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (int)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (long)v);
|
||||
}
|
||||
for (int j = 0; j < ispecial.length; j++) {
|
||||
int intValue = ispecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = intValue;
|
||||
}
|
||||
test_conv_i2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_i2l: b1", i, b1[i], (long)intValue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < lspecial.length; j++) {
|
||||
long longValue = lspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = longValue;
|
||||
}
|
||||
test_conv_l2i(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2i: a1", i, a1[i], (int)longValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = r.nextInt();
|
||||
}
|
||||
test_conv_i2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_i2l: b1", i, b1[i], (long)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextLong();
|
||||
}
|
||||
test_conv_l2i(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2i: a1", i, a1[i], (int)b1[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +509,18 @@ public class TestIntLongVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_i2l(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_l2i(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -557,6 +630,17 @@ public class TestIntLongVect {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_conv_i2l(int[] a, long[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (long)a[i];
|
||||
}
|
||||
}
|
||||
static void test_conv_l2i(int[] a, long[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (int)b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, int elem, int val) {
|
||||
if (elem != val) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestLongFloatVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestLongFloatVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,40 @@ public class TestLongFloatVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static float[] fspecial = {
|
||||
1.0f,
|
||||
-1.0f,
|
||||
0.0f,
|
||||
-0.0f,
|
||||
Float.MAX_VALUE,
|
||||
Float.MIN_VALUE,
|
||||
-Float.MAX_VALUE,
|
||||
-Float.MIN_VALUE,
|
||||
Float.NaN,
|
||||
Float.POSITIVE_INFINITY,
|
||||
Float.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE,
|
||||
-Long.MIN_VALUE
|
||||
};
|
||||
|
||||
private static long[] lspecial = {
|
||||
0,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE,
|
||||
-Long.MIN_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Long + Float vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +113,8 @@ public class TestLongFloatVect {
|
||||
test_vi_unaln(a1, b1, (long)123, 103.f);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_l2f(a1, b1);
|
||||
test_conv_f2l(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +378,41 @@ public class TestLongFloatVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (long)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (float)v);
|
||||
}
|
||||
for (int j = 0; j < lspecial.length; j++) {
|
||||
long longValue = lspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = longValue;
|
||||
}
|
||||
test_conv_l2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2f: b1", i, b1[i], (float)longValue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < fspecial.length; j++) {
|
||||
float floatValue = fspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = floatValue;
|
||||
}
|
||||
test_conv_f2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2l: a1", i, a1[i], (long)floatValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = r.nextLong();
|
||||
}
|
||||
test_conv_l2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2f: b1", i, b1[i], (float)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextFloat();
|
||||
}
|
||||
test_conv_f2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2l: a1", i, a1[i], (long)b1[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +523,18 @@ public class TestLongFloatVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_f2l(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_f2l: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_l2f(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_l2f: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -556,6 +643,16 @@ public class TestLongFloatVect {
|
||||
c[i] = d[i+UNALIGN_OFF];
|
||||
}
|
||||
}
|
||||
static void test_conv_l2f(long[] a, float[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (float)a[i];
|
||||
}
|
||||
}
|
||||
static void test_conv_f2l(long[] a, float[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (long)b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, long elem, long val) {
|
||||
if (elem != val) {
|
||||
@ -565,7 +662,7 @@ public class TestLongFloatVect {
|
||||
return 0;
|
||||
}
|
||||
static int verify(String text, int i, float elem, float val) {
|
||||
if (elem != val) {
|
||||
if (elem != val && !(Float.isNaN(elem) && Float.isNaN(val))) {
|
||||
System.err.println(text + "[" + i + "] = " + elem + " != " + val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestShortDoubleVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestShortDoubleVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,34 @@ public class TestShortDoubleVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static final short[] sspecial = {
|
||||
0, 0x8, 0xF, 0x3F, 0x7C, 0x7F, 0x8F, 0xF3, 0xF8, 0xFF, 0x38FF, (short)0x8F8F,
|
||||
(short)0x8FFF, 0x7FF3, 0x7FFF, (short)0xFF33, (short)0xFFF8, (short)0xFFFF,
|
||||
(short)0xFFFFFF, (short)Integer.MAX_VALUE, (short)Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static final double[] dspecial = {
|
||||
1.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
-0.0,
|
||||
Double.MAX_VALUE,
|
||||
Double.MIN_VALUE,
|
||||
-Double.MAX_VALUE,
|
||||
-Double.MIN_VALUE,
|
||||
Double.NaN,
|
||||
Double.POSITIVE_INFINITY,
|
||||
Double.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
-Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Short + Double vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +107,8 @@ public class TestShortDoubleVect {
|
||||
test_vi_unaln(a1, b1, (short)123, 103.);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_s2d(a1, b1);
|
||||
test_conv_d2s(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,7 +372,41 @@ public class TestShortDoubleVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (short)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (double)v);
|
||||
}
|
||||
|
||||
for (int j = 0; j < sspecial.length; j++) {
|
||||
short shortValue = sspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = shortValue;
|
||||
}
|
||||
test_conv_s2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_s2d: b1", i, b1[i], (double)shortValue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < dspecial.length; j++) {
|
||||
double doubleValue = dspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = doubleValue;
|
||||
}
|
||||
test_conv_d2s(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2s: a1", i, a1[i], (short)doubleValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = (short)r.nextInt();
|
||||
}
|
||||
test_conv_s2d(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_s2d: b1", i, b1[i], (double)a1[i]);
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextDouble();
|
||||
}
|
||||
test_conv_d2s(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_d2s: a1", i, a1[i], (short)b1[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (errn > 0)
|
||||
@ -448,6 +516,18 @@ public class TestShortDoubleVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_s2d(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_s2d: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_d2s(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_d2s: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -556,6 +636,16 @@ public class TestShortDoubleVect {
|
||||
c[i] = d[i+UNALIGN_OFF];
|
||||
}
|
||||
}
|
||||
static void test_conv_s2d(short[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (double) a[i];
|
||||
}
|
||||
}
|
||||
static void test_conv_d2s(short[] a, double[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (short) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, short elem, short val) {
|
||||
if (elem != val) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestShortFloatVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestShortFloatVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,34 @@ public class TestShortFloatVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static final short[] sspecial = {
|
||||
0, 0x8, 0xF, 0x3F, 0x7C, 0x7F, 0x8F, 0xF3, 0xF8, 0xFF, 0x38FF, (short)0x8F8F,
|
||||
(short)0x8FFF, 0x7FF3, 0x7FFF, (short)0xFF33, (short)0xFFF8, (short)0xFFFF,
|
||||
(short)0xFFFFFF, (short)Integer.MAX_VALUE, (short)Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static final float[] fspecial = {
|
||||
1.0f,
|
||||
-1.0f,
|
||||
0.0f,
|
||||
-0.0f,
|
||||
Float.MAX_VALUE,
|
||||
Float.MIN_VALUE,
|
||||
-Float.MAX_VALUE,
|
||||
-Float.MIN_VALUE,
|
||||
Float.NaN,
|
||||
Float.POSITIVE_INFINITY,
|
||||
Float.NEGATIVE_INFINITY,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE,
|
||||
-Long.MIN_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Short + Float vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +107,8 @@ public class TestShortFloatVect {
|
||||
test_vi_unaln(a1, b1, (short)123, 103.f);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_s2f(a1, b1);
|
||||
test_conv_f2s(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,6 +372,41 @@ public class TestShortFloatVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (short)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (float)v);
|
||||
}
|
||||
for (int j = 0; j < sspecial.length; j++) {
|
||||
short shortValue = sspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = shortValue;
|
||||
}
|
||||
test_conv_s2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_s2f: b1", i, b1[i], (float)(shortValue));
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < fspecial.length; j++) {
|
||||
float floatValue = fspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = floatValue;
|
||||
}
|
||||
test_conv_f2s(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2s: a1", i, a1[i], (short)floatValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = (short)r.nextInt();
|
||||
}
|
||||
test_conv_s2f(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_s2f: b1", i, b1[i], (float)(a1[i]));
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextFloat();
|
||||
}
|
||||
test_conv_f2s(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_f2s: a1", i, a1[i], (short)(b1[i]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -448,6 +517,18 @@ public class TestShortFloatVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_s2f(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_s2f: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_f2s(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_f2s: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -556,6 +637,16 @@ public class TestShortFloatVect {
|
||||
c[i] = d[i+UNALIGN_OFF];
|
||||
}
|
||||
}
|
||||
static void test_conv_s2f(short[] a, float[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (float) a[i];
|
||||
}
|
||||
}
|
||||
static void test_conv_f2s(short[] a, float[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (short) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, short elem, short val) {
|
||||
if (elem != val) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -23,9 +23,10 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key randomness
|
||||
* @bug 7119644
|
||||
* @summary Increase superword's vector size up to 256 bits
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -XX:-TieredCompilation -XX:-OptimizeFill
|
||||
* compiler.codegen.TestShortLongVect
|
||||
@ -33,6 +34,9 @@
|
||||
|
||||
package compiler.codegen;
|
||||
|
||||
import java.util.Random;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public class TestShortLongVect {
|
||||
private static final int ARRLEN = 997;
|
||||
private static final int ITERS = 11000;
|
||||
@ -41,6 +45,24 @@ public class TestShortLongVect {
|
||||
private static final int ALIGN_OFF = 8;
|
||||
private static final int UNALIGN_OFF = 5;
|
||||
|
||||
private static final short[] sspecial = {
|
||||
0, 0x8, 0xF, 0x3F, 0x7C, 0x7F, 0x8F, 0xF3, 0xF8, 0xFF, 0x38FF, (short)0x8F8F,
|
||||
(short)0x8FFF, 0x7FF3, 0x7FFF, (short)0xFF33, (short)0xFFF8, (short)0xFFFF,
|
||||
(short)0xFFFFFF, (short)Integer.MAX_VALUE, (short)Integer.MIN_VALUE
|
||||
};
|
||||
|
||||
private static long[] lspecial = {
|
||||
0,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE,
|
||||
-Integer.MIN_VALUE,
|
||||
Long.MAX_VALUE,
|
||||
Long.MIN_VALUE,
|
||||
-Long.MAX_VALUE,
|
||||
-Long.MIN_VALUE
|
||||
};
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing Short + Long vectors");
|
||||
int errn = test();
|
||||
@ -75,6 +97,8 @@ public class TestShortLongVect {
|
||||
test_vi_unaln(a1, b1, (short)123, (long)103);
|
||||
test_cp_unalndst(a1, a2, b1, b2);
|
||||
test_cp_unalnsrc(a1, a2, b1, b2);
|
||||
test_conv_s2l(a1, b1);
|
||||
test_conv_l2s(a1, b1);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -338,7 +362,41 @@ public class TestShortLongVect {
|
||||
errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], (short)v);
|
||||
errn += verify("test_cp_unalnsrc_overlap: b1", i, b1[i], (long)v);
|
||||
}
|
||||
|
||||
for (int j = 0; j < sspecial.length; j++) {
|
||||
short shortValue = sspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = shortValue;
|
||||
}
|
||||
test_conv_s2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_s2l: b1", i, b1[i], (long)(shortValue));
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < lspecial.length; j++) {
|
||||
long longValue = lspecial[j];
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = longValue;
|
||||
}
|
||||
test_conv_l2s(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2s: a1", i, a1[i], (short)longValue);
|
||||
}
|
||||
}
|
||||
Random r = Utils.getRandomInstance();
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
a1[i] = (short)r.nextInt();
|
||||
}
|
||||
test_conv_s2l(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_s2l: b1", i, b1[i], (long)(a1[i]));
|
||||
}
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
b1[i] = r.nextLong();
|
||||
}
|
||||
test_conv_l2s(a1, b1);
|
||||
for (int i = 0; i < ARRLEN; i++) {
|
||||
errn += verify("test_conv_l2s: a1", i, a1[i], (short)b1[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (errn > 0)
|
||||
@ -448,6 +506,18 @@ public class TestShortLongVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_unalnsrc: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_s2l(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_s2l: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_conv_l2s(a1, b1);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_conv_l2s: " + (end - start));
|
||||
return errn;
|
||||
}
|
||||
|
||||
@ -556,6 +626,16 @@ public class TestShortLongVect {
|
||||
c[i] = d[i+UNALIGN_OFF];
|
||||
}
|
||||
}
|
||||
static void test_conv_s2l(short[] a, long[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
b[i] = (long) a[i];
|
||||
}
|
||||
}
|
||||
static void test_conv_l2s(short[] a, long[] b) {
|
||||
for (int i = 0; i < a.length; i+=1) {
|
||||
a[i] = (short) b[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, short elem, short val) {
|
||||
if (elem != val) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, 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
|
||||
@ -196,30 +196,170 @@ public abstract class TypeVectorOperations {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convert_i2f() {
|
||||
public void convertB2D() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resF[i] = (float) ints[i];
|
||||
resD[i] = (double) bytesA[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convert_f2i() {
|
||||
public void convertB2F() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resF[i] = (float) bytesA[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertB2L() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resL[i] = (long) bytesA[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertD2B() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resB[i] = (byte) doubles[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertD2F() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resF[i] = (float) doubles[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertD2I() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resI[i] = (int) doubles[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertD2S() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resS[i] = (short) doubles[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertD2L() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resL[i] = (long) doubles[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertF2I() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resI[i] = (int) floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convert_l2d() {
|
||||
public void convertF2B() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resB[i] = (byte) floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertF2D() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resD[i] = (double) floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertF2L() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resL[i] = (long) floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertF2S() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resS[i] = (short) floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertI2F() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resF[i] = (float) ints[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertI2D() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resD[i] = (double) ints[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertI2L() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resL[i] = (long) ints[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertL2D() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resD[i] = (double) longs[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convert_d2l() {
|
||||
public void convertL2B() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resL[i] = (long) doubles[i];
|
||||
resB[i] = (byte) longs[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertL2F() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resF[i] = (float) longs[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertL2I() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resI[i] = (int) longs[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertL2S() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resS[i] = (short) longs[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertS2D() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resD[i] = (double) shorts[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertS2F() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resF[i] = (float) shorts[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void convertS2L() {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
resL[i] = (long) shorts[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user