Skip to content

Commit

Permalink
Address review feedback and add intrinsify more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang-mono committed Jul 25, 2022
1 parent bc17865 commit e601b9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 1 addition & 9 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6009,16 +6009,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
g_assert (lhs);
int align = mono_class_value_size (klass, NULL);
retval = build_alloca_llvm_type_name (ctx, ret_type, align, "struct_ret");
retval = LLVMBuildLoad2 (builder, ret_type, retval, "struct_ret");

int len;
if (!strcmp ("Vector4", m_class_get_name (klass)))
len = 4;
else if (!strcmp ("Vector2", m_class_get_name (klass)))
len = 2;
else
g_assert_not_reached ();

int len = LLVMGetVectorSize (LLVMTypeOf (lhs));
for (int i = 0; i < len; i++)
{
elem = LLVMBuildExtractElement (builder, lhs, const_int32 (i), "extract_elem");
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4351,6 +4351,7 @@ init_class (MonoClass *klass)

const char *name = m_class_get_name (klass);

#if defined(TARGET_AMD64) || defined(TARGET_ARM64)
/*
* Some of the intrinsics used by the VectorX classes are only implemented on amd64.
* The JIT can't handle SIMD types with != 16 size yet.
Expand All @@ -4360,6 +4361,7 @@ init_class (MonoClass *klass)
if (!strcmp (name, "Vector4"))
mono_class_set_is_simd_type (klass, TRUE);
}
#endif

if (m_class_is_ginst (klass)) {
if (!strcmp (name, "Vector`1") || !strcmp (name, "Vector64`1") || !strcmp (name, "Vector128`1") || !strcmp (name, "Vector256`1")) {
Expand Down
10 changes: 9 additions & 1 deletion src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ emit_sum_vector (MonoCompile *cfg, MonoType *vector_type, MonoTypeEnum element_t
int element_size;
if (!strcmp ("Vector4", m_class_get_name (vector_class)))
element_size = vector_size / 4;
else if (!strcmp ("Vector4", m_class_get_name (vector_class)))
else if (!strcmp ("Vector2", m_class_get_name (vector_class)))
element_size = vector_size / 2;
else {
MonoClass *element_class = mono_class_from_mono_type_internal (get_vector_t_elem_type (vector_type));
Expand Down Expand Up @@ -1560,12 +1560,16 @@ emit_vector64_vector128_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
static guint16 vector2_methods[] = {
SN_ctor,
SN_Abs,
SN_Add,
SN_CopyTo,
SN_Divide,
SN_Dot,
SN_GetElement,
SN_Max,
SN_Min,
SN_Multiply,
SN_SquareRoot,
SN_Subtract,
SN_WithElement,
SN_get_Item,
SN_get_One,
Expand Down Expand Up @@ -1718,6 +1722,10 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
ins->inst_c1 = MONO_TYPE_R4;
return ins;
}
case SN_Add:
case SN_Divide:
case SN_Multiply:
case SN_Subtract:
case SN_op_Addition:
case SN_op_Division:
case SN_op_Multiply:
Expand Down

0 comments on commit e601b9b

Please sign in to comment.