Skip to content

Commit

Permalink
[Mono] Intrinsify Vector WidenLower and WidenUpper on Arm64 (#66512)
Browse files Browse the repository at this point in the history
* Implement WidenLower and WidenUpper

* Restrict code only to Arm64
  • Loading branch information
simonrozsival authored Mar 14, 2022
1 parent edf14c1 commit 5235ea5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,8 @@ static guint16 sri_vector_methods [] = {
SN_ToVector128Unsafe,
SN_ToVector256,
SN_ToVector256Unsafe,
SN_WidenLower,
SN_WidenUpper,
SN_WithElement,
SN_Xor,
};
Expand Down Expand Up @@ -1308,6 +1310,27 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
ins->inst_c1 = arg0_type;
return ins;
}
case SN_WidenLower:
case SN_WidenUpper: {
#ifdef TARGET_ARM64
if (!is_element_type_primitive (fsig->params [0]))
return NULL;

int op = id == SN_WidenLower ? OP_XLOWER : OP_XUPPER;
MonoInst *lower_or_upper_half = emit_simd_ins_for_sig (cfg, klass, op, 0, arg0_type, fsig, args);

if (type_enum_is_float (arg0_type)) {
return emit_simd_ins (cfg, klass, OP_ARM64_FCVTL, lower_or_upper_half->dreg, -1);
} else {
int zero = alloc_ireg (cfg);
MONO_EMIT_NEW_ICONST (cfg, zero, 0);
op = type_enum_is_unsigned (arg0_type) ? OP_ARM64_USHLL : OP_ARM64_SSHLL;
return emit_simd_ins (cfg, klass, op, lower_or_upper_half->dreg, zero);
}
#else
return NULL;
#endif
}
case SN_WithLower:
case SN_WithUpper: {
if (!is_element_type_primitive (fsig->params [0]))
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/simd-methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ METHOD(ToVector128)
METHOD(ToVector128Unsafe)
METHOD(ToVector256)
METHOD(ToVector256Unsafe)
METHOD(WidenLower)
METHOD(WidenUpper)
METHOD(WithElement)
METHOD(WithLower)
METHOD(WithUpper)
Expand Down

0 comments on commit 5235ea5

Please sign in to comment.