From 5235ea5b982ff9598245bab600353cccfe6618f5 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 14 Mar 2022 19:44:47 +0100 Subject: [PATCH] [Mono] Intrinsify Vector WidenLower and WidenUpper on Arm64 (#66512) * Implement WidenLower and WidenUpper * Restrict code only to Arm64 --- src/mono/mono/mini/simd-intrinsics.c | 23 +++++++++++++++++++++++ src/mono/mono/mini/simd-methods.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index c044ca6604a49f..750f2d87545f59 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -898,6 +898,8 @@ static guint16 sri_vector_methods [] = { SN_ToVector128Unsafe, SN_ToVector256, SN_ToVector256Unsafe, + SN_WidenLower, + SN_WidenUpper, SN_WithElement, SN_Xor, }; @@ -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])) diff --git a/src/mono/mono/mini/simd-methods.h b/src/mono/mono/mini/simd-methods.h index b1dea581c44182..8f2d64e7b24d72 100644 --- a/src/mono/mono/mini/simd-methods.h +++ b/src/mono/mono/mini/simd-methods.h @@ -84,6 +84,8 @@ METHOD(ToVector128) METHOD(ToVector128Unsafe) METHOD(ToVector256) METHOD(ToVector256Unsafe) +METHOD(WidenLower) +METHOD(WidenUpper) METHOD(WithElement) METHOD(WithLower) METHOD(WithUpper)