Skip to content

Commit

Permalink
Refine elem to array elem check. (openjdk#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSandoz committed Apr 19, 2021
1 parent 3e8f093 commit a6e9e03
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/hotspot/share/opto/vectorIntrinsics.cpp
Expand Up @@ -618,6 +618,19 @@ bool LibraryCallKit::inline_vector_broadcast_coerced() {
return true;
}

static bool elem_consistent_with_arr(BasicType elem_bt, const TypeAryPtr* arr_type) {
assert(arr_type != NULL, "unexpected");
BasicType arr_elem_bt = arr_type->elem()->array_element_basic_type();
if (elem_bt == arr_elem_bt) {
return true;
} else if (elem_bt == T_SHORT && arr_elem_bt == T_CHAR) {
// Load/store of short vector from/to char[] is supported
return true;
} else {
return false;
}
}

// <C, V extends Vector<?,?>>
// V load(Class<?> vectorClass, Class<?> elementType, int vlen,
// Object base, long offset,
Expand Down Expand Up @@ -696,7 +709,12 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) {
bool using_byte_array = arr_type != NULL && arr_type->elem()->array_element_basic_type() == T_BYTE && elem_bt != T_BYTE;
// Handle loading masks.
// If there is no consistency between array and vector element types, it must be special byte array case or loading masks
if (arr_type != NULL && !using_byte_array && elem_bt != arr_type->elem()->array_element_basic_type() && !is_mask) {
if (arr_type != NULL && !using_byte_array && !is_mask && !elem_consistent_with_arr(elem_bt, arr_type)) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: arity=%d op=%s vlen=%d etype=%s atype=%s ismask=no",
is_store, is_store ? "store" : "load",
num_elem, type2name(elem_bt), type2name(arr_type->elem()->array_element_basic_type()));
}
set_map(old_map);
set_sp(old_sp);
return false;
Expand Down Expand Up @@ -879,7 +897,12 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) {
const TypeAryPtr* arr_type = addr_type->isa_aryptr();

// The array must be consistent with vector type
if (arr_type == NULL || (arr_type != NULL && elem_bt != arr_type->elem()->array_element_basic_type())) {
if (arr_type == NULL || (arr_type != NULL && !elem_consistent_with_arr(elem_bt, arr_type))) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: arity=%d op=%s vlen=%d etype=%s atype=%s ismask=no",
is_scatter, is_scatter ? "scatter" : "gather",
num_elem, type2name(elem_bt), type2name(arr_type->elem()->array_element_basic_type()));
}
set_map(old_map);
set_sp(old_sp);
return false;
Expand Down

0 comments on commit a6e9e03

Please sign in to comment.