Skip to content

Commit 5235ea5

Browse files
[Mono] Intrinsify Vector WidenLower and WidenUpper on Arm64 (#66512)
* Implement WidenLower and WidenUpper * Restrict code only to Arm64
1 parent edf14c1 commit 5235ea5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/mono/mono/mini/simd-intrinsics.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ static guint16 sri_vector_methods [] = {
898898
SN_ToVector128Unsafe,
899899
SN_ToVector256,
900900
SN_ToVector256Unsafe,
901+
SN_WidenLower,
902+
SN_WidenUpper,
901903
SN_WithElement,
902904
SN_Xor,
903905
};
@@ -1308,6 +1310,27 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
13081310
ins->inst_c1 = arg0_type;
13091311
return ins;
13101312
}
1313+
case SN_WidenLower:
1314+
case SN_WidenUpper: {
1315+
#ifdef TARGET_ARM64
1316+
if (!is_element_type_primitive (fsig->params [0]))
1317+
return NULL;
1318+
1319+
int op = id == SN_WidenLower ? OP_XLOWER : OP_XUPPER;
1320+
MonoInst *lower_or_upper_half = emit_simd_ins_for_sig (cfg, klass, op, 0, arg0_type, fsig, args);
1321+
1322+
if (type_enum_is_float (arg0_type)) {
1323+
return emit_simd_ins (cfg, klass, OP_ARM64_FCVTL, lower_or_upper_half->dreg, -1);
1324+
} else {
1325+
int zero = alloc_ireg (cfg);
1326+
MONO_EMIT_NEW_ICONST (cfg, zero, 0);
1327+
op = type_enum_is_unsigned (arg0_type) ? OP_ARM64_USHLL : OP_ARM64_SSHLL;
1328+
return emit_simd_ins (cfg, klass, op, lower_or_upper_half->dreg, zero);
1329+
}
1330+
#else
1331+
return NULL;
1332+
#endif
1333+
}
13111334
case SN_WithLower:
13121335
case SN_WithUpper: {
13131336
if (!is_element_type_primitive (fsig->params [0]))

src/mono/mono/mini/simd-methods.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ METHOD(ToVector128)
8484
METHOD(ToVector128Unsafe)
8585
METHOD(ToVector256)
8686
METHOD(ToVector256Unsafe)
87+
METHOD(WidenLower)
88+
METHOD(WidenUpper)
8789
METHOD(WithElement)
8890
METHOD(WithLower)
8991
METHOD(WithUpper)

0 commit comments

Comments
 (0)