JIT: Use ValueTuple argument for SIMD type lookup for AdvSimd.Store*#107099
Conversation
|
@tannergooding I did a quick parse of the intrinsics that take |
| HARDWARE_INTRINSIC(AdvSimd, SignExtendWideningUpper, 16, 1, {INS_sxtl2, INS_invalid, INS_sxtl2, INS_invalid, INS_sxtl2, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_BaseTypeFromFirstArg) | ||
| HARDWARE_INTRINSIC(AdvSimd, SqrtScalar, 8, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_fsqrt, INS_fsqrt}, HW_Category_SIMD, HW_Flag_SIMDScalar) | ||
| HARDWARE_INTRINSIC(AdvSimd, Store, 8, 2, {INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_invalid, INS_invalid, INS_st1_2regs, INS_invalid}, HW_Category_MemoryStore, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_NeedsConsecutiveRegisters) | ||
| HARDWARE_INTRINSIC(AdvSimd, Store, 8, 2, {INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_invalid, INS_invalid, INS_st1_2regs, INS_invalid}, HW_Category_MemoryStore, HW_Flag_BaseTypeFromSecondArg|HW_Flag_BaseTypeFromValueTupleArg|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_NeedsConsecutiveRegisters) |
There was a problem hiding this comment.
The SIMD size here isn't correct as the size is not always 8. Consider, for example:
or in the case of AdvSimd_Arm64:
There was a problem hiding this comment.
I see, so this one needs to look up the size at runtime, too. Let me fix that.
| HARDWARE_INTRINSIC(AdvSimd_Arm64, ShiftRightLogicalRoundedNarrowingSaturateScalar, 8, 2, {INS_uqrshrn, INS_uqrshrn, INS_uqrshrn, INS_uqrshrn, INS_uqrshrn, INS_uqrshrn, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_ShiftRightByImmediate, HW_Flag_HasImmediateOperand|HW_Flag_SIMDScalar) | ||
| HARDWARE_INTRINSIC(AdvSimd_Arm64, Sqrt, -1, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_fsqrt, INS_fsqrt}, HW_Category_SIMD, HW_Flag_NoFlag) | ||
| HARDWARE_INTRINSIC(AdvSimd_Arm64, Store, 16, 2, {INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs}, HW_Category_MemoryStore, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_NeedsConsecutiveRegisters) | ||
| HARDWARE_INTRINSIC(AdvSimd_Arm64, Store, -1, 2, {INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs, INS_st1_2regs}, HW_Category_MemoryStore, HW_Flag_BaseTypeFromSecondArg|HW_Flag_BaseTypeFromValueTupleArg|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_NeedsConsecutiveRegisters) |
There was a problem hiding this comment.
I believe this one only has overloads dealing with Vector128
There was a problem hiding this comment.
You're right; fixed.
tannergooding
left a comment
There was a problem hiding this comment.
LGTM. I believe this is all the places that are using tuple and that had been changed from .NET 8, but I notably did not compare line by line to find any other places that may have gotten incorrectly changed
There is also |
|
@tannergooding should this be backported to .NET 9, since we fixed the SIMD size lookup for |
Follow-up to #106765.
StoreandStoreVectorAndZip, likeStoreSelectedScalar, have variants that operate onValueTuplesofVectors, and in the case of the former intrinsic, the SIMD size has to be determined at runtime since it can operate on 64- and 128-bitVectors. Thus, the JIT needs to determine theVectorsize used by the intrinsic overloads'ValueTupleargument.There are a few other intrinsics (like
LoadAndInsertScalar) that also operate onValueTuples, and the JIT currently differentiates between these variants with dedicatedNamedIntrinsics(LoadAndInsertScalarVector64x2,LoadAndInsertScalarVector64x3, etc). I think these can be unified into oneNamedIntrinsicand use theValueTuplelookup logic, in case we want to clean these up.