Skip to content

Commit e928f16

Browse files
authored
ExtractMSB arm64 LLVM + refactor mini JIT op codes (#89431)
1 parent a0a8ce6 commit e928f16

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

src/mono/mono/mini/cpu-arm64.mdesc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,6 @@ arm64_xtn2: dest:x src1:x src2:x len:4 clob:1
553553
arm64_fcvtn: dest:x src1:x len:4
554554
arm64_fcvtn2: dest:x src1:x src2:x len:4 clob:1
555555
xunop: dest:x src1:x len:4
556-
arm64_ushl: dest:x src1:x src2:x len:4
557-
arm64_ext_imm: dest:x src1:x src2:x len:4
558556
xinsert_i8: dest:x src1:x src2:i src3:i len:20
559557
xinsert_r8: dest:x src1:x src2:f src3:i len:20
560558
arm64_broadcast_elem: dest:x src1:x len:16

src/mono/mono/mini/mini-arm64.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,6 +3870,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
38703870
case INTRINS_AARCH64_ADV_SIMD_TBL1:
38713871
arm_neon_tbl1_16b (code, dreg, sreg1, sreg2);
38723872
break;
3873+
case INTRINS_AARCH64_ADV_SIMD_USHL:
3874+
arm_neon_ushl (code, get_vector_size_macro (ins), get_type_size_macro (ins->inst_c1), dreg, sreg1, sreg2);
3875+
break;
38733876
default:
38743877
g_assert_not_reached ();
38753878
break;
@@ -4138,17 +4141,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
41384141
arm_neon_ins_e (code, SIZE_8, dreg, sreg2, 1, 0);
41394142
break;
41404143
}
4141-
case OP_ARM64_USHL: {
4142-
arm_neon_ushl (code, get_vector_size_macro (ins), get_type_size_macro (ins->inst_c1), dreg, sreg1, sreg2);
4143-
break;
4144-
}
4145-
case OP_ARM64_EXT_IMM: {
4146-
if (get_vector_size_macro (ins) == VREG_LOW)
4147-
arm_neon_ext_8b (code, dreg, sreg1, sreg2, ins->inst_c0);
4148-
else
4149-
arm_neon_ext_16b (code, dreg, sreg1, sreg2, ins->inst_c0);
4150-
break;
4151-
}
41524144
case OP_XLOWER: {
41534145
if (dreg == sreg1) {
41544146
// clean the upper half

src/mono/mono/mini/mini-ops.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,6 @@ MINI_OP(OP_ARM64_ABSCOMPARE, "arm64_abscompare", XREG, XREG, XREG)
17921792
MINI_OP(OP_ARM64_XNARROW_SCALAR, "arm64_xnarrow_scalar", XREG, XREG, NONE)
17931793

17941794
MINI_OP3(OP_ARM64_EXT, "arm64_ext", XREG, XREG, XREG, IREG)
1795-
MINI_OP(OP_ARM64_EXT_IMM, "arm64_ext_imm", XREG, XREG, XREG)
17961795

17971796
MINI_OP3(OP_ARM64_SQRDMLAH, "arm64_sqrdmlah", XREG, XREG, XREG, XREG)
17981797
MINI_OP3(OP_ARM64_SQRDMLAH_BYSCALAR, "arm64_sqrdmlah_byscalar", XREG, XREG, XREG, XREG)
@@ -1809,8 +1808,6 @@ MINI_OP3(OP_ARM64_SQRDMLSH_SCALAR, "arm64_sqrdmlsh_scalar", XREG, XREG, XREG, XR
18091808
MINI_OP(OP_ARM64_TBL_INDIRECT, "arm64_tbl_indirect", XREG, IREG, XREG)
18101809
MINI_OP3(OP_ARM64_TBX_INDIRECT, "arm64_tbx_indirect", XREG, IREG, XREG, XREG)
18111810

1812-
MINI_OP(OP_ARM64_USHL, "arm64_ushl", XREG, XREG, XREG)
1813-
18141811
#endif // TARGET_ARM64
18151812

18161813
MINI_OP(OP_SIMD_FCVTL, "simd_convert_to_higher_precision", XREG, XREG, NONE)

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,9 +1805,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
18051805
#ifdef TARGET_WASM
18061806
return emit_simd_ins_for_sig (cfg, klass, OP_WASM_SIMD_BITMASK, -1, -1, fsig, args);
18071807
#elif defined(TARGET_ARM64)
1808-
if (COMPILE_LLVM (cfg))
1809-
return NULL;
1810-
18111808
MonoInst* result_ins = NULL;
18121809
MonoClass* arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
18131810
int size = mono_class_value_size (arg_class, NULL);
@@ -1819,27 +1816,22 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
18191816
and_res_vec->sreg2 = msb_mask_vec->dreg;
18201817

18211818
MonoInst* msb_shift_vec = emit_msb_shift_vector_constant (cfg, arg_class, arg0_type);
1822-
MonoInst* shift_res_vec = emit_simd_ins (cfg, arg_class, OP_ARM64_USHL, and_res_vec->dreg, msb_shift_vec->dreg);
1819+
1820+
MonoInst* shift_res_vec = emit_simd_ins (cfg, arg_class, OP_XOP_OVR_X_X_X, and_res_vec->dreg, msb_shift_vec->dreg);
1821+
shift_res_vec->inst_c0 = INTRINS_AARCH64_ADV_SIMD_USHL;
18231822
shift_res_vec->inst_c1 = arg0_type;
18241823

18251824
if (arg0_type == MONO_TYPE_I1 || arg0_type == MONO_TYPE_U1) {
1826-
// Always perform usigned operations as vector sum and extract operations could sign-extend the result into the GP register
1825+
// Always perform unsigned operations as vector sum and extract operations could sign-extend the result into the GP register
18271826
// making the final result invalid. This is not needed for wider type as the maximum sum of extracted MSB cannot be larger than 8bits
18281827
arg0_type = MONO_TYPE_U1;
18291828

1830-
// In order to sum high and low 64bits of the shifted vector separatly, we use a zeroed vector and the extract operation
1831-
MonoInst* zero_vec = emit_xzero(cfg, arg_class);
1832-
1833-
MonoInst* ext_low_vec = emit_simd_ins (cfg, arg_class, OP_ARM64_EXT_IMM, zero_vec->dreg, shift_res_vec->dreg);
1834-
ext_low_vec->inst_c0 = 8;
1835-
ext_low_vec->inst_c1 = arg0_type;
1829+
MonoInst* ext_low_vec = emit_simd_ins_for_sig (cfg, arg_class, OP_XLOWER, 8, arg0_type, fsig, &shift_res_vec);
18361830
MonoInst* sum_low_vec = emit_sum_vector (cfg, fsig->params [0], arg0_type, ext_low_vec);
1837-
1838-
MonoInst* ext_high_vec = emit_simd_ins (cfg, arg_class, OP_ARM64_EXT_IMM, shift_res_vec->dreg, zero_vec->dreg);
1839-
ext_high_vec->inst_c0 = 8;
1840-
ext_high_vec->inst_c1 = arg0_type;
1841-
MonoInst* sum_high_vec = emit_sum_vector (cfg, fsig->params [0], arg0_type, ext_high_vec);
1842-
1831+
1832+
MonoInst* ext_high_vec = emit_simd_ins_for_sig (cfg, arg_class, OP_XUPPER, 8, arg0_type, fsig, &shift_res_vec);
1833+
MonoInst* sum_high_vec = emit_sum_vector (cfg, fsig->params [0], arg0_type, ext_high_vec);
1834+
18431835
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHL_IMM, sum_high_vec->dreg, sum_high_vec->dreg, 8);
18441836
EMIT_NEW_BIALU (cfg, result_ins, OP_IOR, sum_high_vec->dreg, sum_high_vec->dreg, sum_low_vec->dreg);
18451837
} else {

0 commit comments

Comments
 (0)