Repository navigation
Description
The A32 variants of these are blocked pending resolution of the <lanes>x<copies> implementation in #24790 (e.g. int32x2x2). The permute instructions such as ZIP1 and ZIP2 present an interesting challenge. Since intrinsics in CoreCLR/CoreFX are supposed to match down to a single hardware instruction this makes it a bit awkward, since on A32 ZIP, TRN, UZP are destructive operations which perform both the Odd and Even shuffles at the same time. So while you could do the intrinsics for A32 by copying the vector and ignoring one of the outputs I believe that goes counter to the philosophy here (unless I'm mistaken.). It also means that if they were to be implemented on A32 for efficiency a ZIP1, ZIP2 combo should be combined to ZIP and the moves not generated.
This also means that the Arm ZIP, TRN, UZP intrinsics can't be implemented in A64 as a single intrinsics but rather the user needs to make two calls. This is the reason that in this proposal the intrinsics are A64 only, but it makes intrinsics code between A32 and A64 a bit less portable in this case.
Also to make things easier to read I combined the documentation headers for the proposal. They will of course be separated out in the actual implementation
namespace System.Runtime.Intrinsics.Arm
{
public static class ArmBase
{
public static bool IsSupported { get { throw null; } }
/// <summary>
/// vslid_n_[su]64
///
/// A64: SLI
/// A32: VSLI
/// </summary>
public static long LeftShiftAndInsert (long left, long right, uint shift) => { throw null };
public static ulong LeftShiftAndInsert (ulong left, ulong right, uint shift) => { throw null };
/// <summary>
/// vsrid_n_[su]64
///
/// A64: SRI
/// A32: VSRI
/// </summary>
public static long RightShiftAndInsert (long left, long right, uint shift) => { throw null };
public static ulong RightShiftAndInsert (ulong left, ulong right, uint shift) => { throw null };
}
public static class AdvSimd
{
public static bool IsSupported { get { throw null; } }
/// <summary>
/// vsli[q]_n_[su][8,16,32,64]
//
/// A64: SLI
/// A32: VSLI
/// </summary>
public static Vector64<byte> LeftShiftAndInsert (Vector64<byte> left, Vector64<byte> right, uint shift) => { throw null };
public static Vector64<ushort> LeftShiftAndInsert (Vector64<ushort> left, Vector64<ushort> right, uint shift) => { throw null };
public static Vector64<uint> LeftShiftAndInsert (Vector64<uint> left, Vector64<uint> right, uint shift) => { throw null };
public static Vector64<sbyte> LeftShiftAndInsert (Vector64<sbyte> left, Vector64<sbyte> right, uint shift) => { throw null };
public static Vector64<short> LeftShiftAndInsert (Vector64<short> left, Vector64<short> right, uint shift) => { throw null };
public static Vector64<int> LeftShiftAndInsert (Vector64<int> left, Vector64<int> right, uint shift) => { throw null };
public static Vector128<byte> LeftShiftAndInsert (Vector128<byte> left, Vector128<byte> right, uint shift) => { throw null };
public static Vector128<ushort> LeftShiftAndInsert (Vector128<ushort> left, Vector128<ushort> right, uint shift) => { throw null };
public static Vector128<uint> LeftShiftAndInsert (Vector128<uint> left, Vector128<uint> right, uint shift) => { throw null };
public static Vector128<ulong> LeftShiftAndInsert (Vector128<ulong> left, Vector128<ulong> right, uint shift) => { throw null };
public static Vector128<sbyte> LeftShiftAndInsert (Vector128<sbyte> left, Vector128<sbyte> right, uint shift) => { throw null };
public static Vector128<short> LeftShiftAndInsert (Vector128<short> left, Vector128<short> right, uint shift) => { throw null };
public static Vector128<int> LeftShiftAndInsert (Vector128<int> left, Vector128<int> right, uint shift) => { throw null };
public static Vector128<long> LeftShiftAndInsert (Vector128<long> left, Vector128<long> right, uint shift) => { throw null };
/// <summary>
/// vsri[q]_n_[su][8,16,32,64]
///
/// A64: SRI
/// A32: VSRI
/// </summary>
public static Vector64<byte> RightShiftAndInsert (Vector64<byte> left, Vector64<byte> right, uint shift) => { throw null };
public static Vector64<ushort> RightShiftAndInsert (Vector64<ushort> left, Vector64<ushort> right, uint shift) => { throw null };
public static Vector64<uint> RightShiftAndInsert (Vector64<uint> left, Vector64<uint> right, uint shift) => { throw null };
public static Vector64<sbyte> RightShiftAndInsert (Vector64<sbyte> left, Vector64<sbyte> right, uint shift) => { throw null };
public static Vector64<short> RightShiftAndInsert (Vector64<short> left, Vector64<short> right, uint shift) => { throw null };
public static Vector64<int> RightShiftAndInsert (Vector64<int> left, Vector64<int> right, uint shift) => { throw null };
public static Vector128<byte> RightShiftAndInsert (Vector128<byte> left, Vector128<byte> right, uint shift) => { throw null };
public static Vector128<ushort> RightShiftAndInsert (Vector128<ushort> left, Vector128<ushort> right, uint shift) => { throw null };
public static Vector128<uint> RightShiftAndInsert (Vector128<uint> left, Vector128<uint> right, uint shift) => { throw null };
public static Vector128<ulong> RightShiftAndInsert (Vector128<ulong> left, Vector128<ulong> right, uint shift) => { throw null };
public static Vector128<sbyte> RightShiftAndInsert (Vector128<sbyte> left, Vector128<sbyte> right, uint shift) => { throw null };
public static Vector128<short> RightShiftAndInsert (Vector128<short> left, Vector128<short> right, uint shift) => { throw null };
public static Vector128<int> RightShiftAndInsert (Vector128<int> left, Vector128<int> right, uint shift) => { throw null };
public static Vector128<long> RightShiftAndInsert (Vector128<long> left, Vector128<long> right, uint shift) => { throw null };
/// <summary>
/// vmovn_[su][16,32,64]
///
/// A64: XTN
/// A32: VMOVN
/// </summary>
public static Vector64<sbyte> ExtractAndNarrowLow (Vector128<short> value) => { throw null };
public static Vector64<short> ExtractAndNarrowLow (Vector128<int> value) => { throw null };
public static Vector64<int> ExtractAndNarrowLow (Vector128<long> value) => { throw null };
public static Vector64<byte> ExtractAndNarrowLow (Vector128<ushort> value) => { throw null };
public static Vector64<ushort> ExtractAndNarrowLow (Vector128<uint> value) => { throw null };
public static Vector64<uint> ExtractAndNarrowLow (Vector128<ulong> value) => { throw null };
/// <summary>
/// vmovn_high_[su][16,32,64]
//
/// A64: XTN2
/// A32: VMOVN
/// </summary>
public static Vector128<sbyte> ExtractAndNarrowHigh (Vector64<sbyte> accum, Vector128<short> value) => { throw null };
public static Vector128<short> ExtractAndNarrowHigh (Vector64<short> accum, Vector128<int> value) => { throw null };
public static Vector128<int> ExtractAndNarrowHigh (Vector64<int> accum, Vector128<long> value) => { throw null };
public static Vector128<byte> ExtractAndNarrowHigh (Vector64<byte> accum, Vector128<ushort> value) => { throw null };
public static Vector128<ushort> ExtractAndNarrowHigh (Vector64<ushort> accum, Vector128<uint> value) => { throw null };
public static Vector128<uint> ExtractAndNarrowHigh (Vector64<uint> accum, Vector128<ulong> value) => { throw null };
public static class Arm64
{
public static bool IsSupported { get { throw null; } }
/// <summary>
/// vtrn1[q]_[suf][8,16,32,64]
///
/// A64: UZP1
/// </summary>
public static Vector64<sbyte> UnzipEven (Vector64<sbyte> left, Vector64<sbyte> right) => { throw null };
public static Vector64<short> UnzipEven (Vector64<short> left, Vector64<short> right) => { throw null };
public static Vector64<int> UnzipEven (Vector64<int> left, Vector64<int> right) => { throw null };
public static Vector64<byte> UnzipEven (Vector64<byte> left, Vector64<byte> right) => { throw null };
public static Vector64<ushort> UnzipEven (Vector64<ushort> left, Vector64<ushort> right) => { throw null };
public static Vector64<uint> UnzipEven (Vector64<uint> left, Vector64<uint> right) => { throw null };
public static Vector64<float> UnzipEven (Vector64<float> left, Vector64<float> right) => { throw null };
public static Vector128<sbyte> UnzipEven (Vector128<sbyte> left, Vector128<sbyte> right) => { throw null };
public static Vector128<short> UnzipEven (Vector128<short> left, Vector128<short> right) => { throw null };
public static Vector128<int> UnzipEven (Vector128<int> left, Vector128<int> right) => { throw null };
public static Vector128<long> UnzipEven (Vector128<long> left, Vector128<long> right) => { throw null };
public static Vector128<byte> UnzipEven (Vector128<byte> left, Vector128<byte> right) => { throw null };
public static Vector128<ushort> UnzipEven (Vector128<ushort> left, Vector128<ushort> right) => { throw null };
public static Vector128<uint> UnzipEven (Vector128<uint> left, Vector128<uint> right) => { throw null };
public static Vector128<ulong> UnzipEven (Vector128<ulong> left, Vector128<ulong> right) => { throw null };
public static Vector128<float> UnzipEven (Vector128<float> left, Vector128<float> right) => { throw null };
public static Vector128<double> UnzipEven (Vector128<double> left, Vector128<double> right) => { throw null };
/// <summary>
/// vtrn2[q]_[suf][8,16,32,64]
///
/// A64: UZP2
/// </summary>
public static Vector64<sbyte> UnzipOdd (Vector64<sbyte> left, Vector64<sbyte> right) => { throw null };
public static Vector64<short> UnzipOdd (Vector64<short> left, Vector64<short> right) => { throw null };
public static Vector64<int> UnzipOdd (Vector64<int> left, Vector64<int> right) => { throw null };
public static Vector64<byte> UnzipOdd (Vector64<byte> left, Vector64<byte> right) => { throw null };
public static Vector64<ushort> UnzipOdd (Vector64<ushort> left, Vector64<ushort> right) => { throw null };
public static Vector64<uint> UnzipOdd (Vector64<uint> left, Vector64<uint> right) => { throw null };
public static Vector64<float> UnzipOdd (Vector64<float> left, Vector64<float> right) => { throw null };
public static Vector128<sbyte> UnzipOdd (Vector128<sbyte> left, Vector128<sbyte> right) => { throw null };
public static Vector128<short> UnzipOdd (Vector128<short> left, Vector128<short> right) => { throw null };
public static Vector128<int> UnzipOdd (Vector128<int> left, Vector128<int> right) => { throw null };
public static Vector128<long> UnzipOdd (Vector128<long> left, Vector128<long> right) => { throw null };
public static Vector128<byte> UnzipOdd (Vector128<byte> left, Vector128<byte> right) => { throw null };
public static Vector128<ushort> UnzipOdd (Vector128<ushort> left, Vector128<ushort> right) => { throw null };
public static Vector128<uint> UnzipOdd (Vector128<uint> left, Vector128<uint> right) => { throw null };
public static Vector128<ulong> UnzipOdd (Vector128<ulong> left, Vector128<ulong> right) => { throw null };
public static Vector128<float> UnzipOdd (Vector128<float> left, Vector128<float> right) => { throw null };
public static Vector128<double> UnzipOdd (Vector128<double> left, Vector128<double> right) => { throw null };
/// <summary>
/// vzip1[q]_[suf][8,16,32,64]
///
/// A64: ZIP1
/// </summary>
public static Vector64<sbyte> ZipLow (Vector64<sbyte> left, Vector64<sbyte> right) => { throw null };
public static Vector64<short> ZipLow (Vector64<short> left, Vector64<short> right) => { throw null };
public static Vector64<int> ZipLow (Vector64<int> left, Vector64<int> right) => { throw null };
public static Vector64<byte> ZipLow (Vector64<byte> left, Vector64<byte> right) => { throw null };
public static Vector64<ushort> ZipLow (Vector64<ushort> left, Vector64<ushort> right) => { throw null };
public static Vector64<uint> ZipLow (Vector64<uint> left, Vector64<uint> right) => { throw null };
public static Vector64<float> ZipLow (Vector64<float> left, Vector64<float> right) => { throw null };
public static Vector128<sbyte> ZipLow (Vector128<sbyte> left, Vector128<sbyte> right) => { throw null };
public static Vector128<short> ZipLow (Vector128<short> left, Vector128<short> right) => { throw null };
public static Vector128<int> ZipLow (Vector128<int> left, Vector128<int> right) => { throw null };
public static Vector128<long> ZipLow (Vector128<long> left, Vector128<long> right) => { throw null };
public static Vector128<byte> ZipLow (Vector128<byte> left, Vector128<byte> right) => { throw null };
public static Vector128<ushort> ZipLow (Vector128<ushort> left, Vector128<ushort> right) => { throw null };
public static Vector128<uint> ZipLow (Vector128<uint> left, Vector128<uint> right) => { throw null };
public static Vector128<ulong> ZipLow (Vector128<ulong> left, Vector128<ulong> right) => { throw null };
public static Vector128<float> ZipLow (Vector128<float> left, Vector128<float> right) => { throw null };
public static Vector128<double> ZipLow (Vector128<double> left, Vector128<double> right) => { throw null };
/// <summary>
/// vzip2[q]_[suf][8,16,32,64]
///
/// A64: ZIP2
/// </summary>
public static Vector64<sbyte> ZipHigh (Vector64<sbyte> left, Vector64<sbyte> right) => { throw null };
public static Vector64<short> ZipHigh (Vector64<short> left, Vector64<short> right) => { throw null };
public static Vector64<int> ZipHigh (Vector64<int> left, Vector64<int> right) => { throw null };
public static Vector64<byte> ZipHigh (Vector64<byte> left, Vector64<byte> right) => { throw null };
public static Vector64<ushort> ZipHigh (Vector64<ushort> left, Vector64<ushort> right) => { throw null };
public static Vector64<uint> ZipHigh (Vector64<uint> left, Vector64<uint> right) => { throw null };
public static Vector64<float> ZipHigh (Vector64<float> left, Vector64<float> right) => { throw null };
public static Vector128<sbyte> ZipHigh (Vector128<sbyte> left, Vector128<sbyte> right) => { throw null };
public static Vector128<short> ZipHigh (Vector128<short> left, Vector128<short> right) => { throw null };
public static Vector128<int> ZipHigh (Vector128<int> left, Vector128<int> right) => { throw null };
public static Vector128<long> ZipHigh (Vector128<long> left, Vector128<long> right) => { throw null };
public static Vector128<byte> ZipHigh (Vector128<byte> left, Vector128<byte> right) => { throw null };
public static Vector128<ushort> ZipHigh (Vector128<ushort> left, Vector128<ushort> right) => { throw null };
public static Vector128<uint> ZipHigh (Vector128<uint> left, Vector128<uint> right) => { throw null };
public static Vector128<ulong> ZipHigh (Vector128<ulong> left, Vector128<ulong> right) => { throw null };
public static Vector128<float> ZipHigh (Vector128<float> left, Vector128<float> right) => { throw null };
public static Vector128<double> ZipHigh (Vector128<double> left, Vector128<double> right) => { throw null };
/// <summary>
/// vtrn1[q]_[suf][8,16,32,64]
///
/// A64: TRN1
/// </summary>
public static Vector64<sbyte> TransposeEven (Vector64<sbyte> left, Vector64<sbyte> right) => { throw null };
public static Vector64<short> TransposeEven (Vector64<short> left, Vector64<short> right) => { throw null };
public static Vector64<int> TransposeEven (Vector64<int> left, Vector64<int> right) => { throw null };
public static Vector64<byte> TransposeEven (Vector64<byte> left, Vector64<byte> right) => { throw null };
public static Vector64<ushort> TransposeEven (Vector64<ushort> left, Vector64<ushort> right) => { throw null };
public static Vector64<uint> TransposeEven (Vector64<uint> left, Vector64<uint> right) => { throw null };
public static Vector64<float> TransposeEven (Vector64<float> left, Vector64<float> right) => { throw null };
public static Vector128<sbyte> TransposeEven (Vector128<sbyte> left, Vector128<sbyte> right) => { throw null };
public static Vector128<short> TransposeEven (Vector128<short> left, Vector128<short> right) => { throw null };
public static Vector128<int> TransposeEven (Vector128<int> left, Vector128<int> right) => { throw null };
public static Vector128<long> TransposeEven (Vector128<long> left, Vector128<long> right) => { throw null };
public static Vector128<byte> TransposeEven (Vector128<byte> left, Vector128<byte> right) => { throw null };
public static Vector128<ushort> TransposeEven (Vector128<ushort> left, Vector128<ushort> right) => { throw null };
public static Vector128<uint> TransposeEven (Vector128<uint> left, Vector128<uint> right) => { throw null };
public static Vector128<ulong> TransposeEven (Vector128<ulong> left, Vector128<ulong> right) => { throw null };
public static Vector128<float> TransposeEven (Vector128<float> left, Vector128<float> right) => { throw null };
public static Vector128<double> TransposeEven (Vector128<double> left, Vector128<double> right) => { throw null };
/// <summary>
/// vtrn2[q]_[suf][8,16,32,64]
///
/// A64: TRN2
/// </summary>
public static Vector64<sbyte> TransposeOdd (Vector64<sbyte> left, Vector64<sbyte> right) => { throw null };
public static Vector64<short> TransposeOdd (Vector64<short> left, Vector64<short> right) => { throw null };
public static Vector64<int> TransposeOdd (Vector64<int> left, Vector64<int> right) => { throw null };
public static Vector64<byte> TransposeOdd (Vector64<byte> left, Vector64<byte> right) => { throw null };
public static Vector64<ushort> TransposeOdd (Vector64<ushort> left, Vector64<ushort> right) => { throw null };
public static Vector64<uint> TransposeOdd (Vector64<uint> left, Vector64<uint> right) => { throw null };
public static Vector64<float> TransposeOdd (Vector64<float> left, Vector64<float> right) => { throw null };
public static Vector128<sbyte> TransposeOdd (Vector128<sbyte> left, Vector128<sbyte> right) => { throw null };
public static Vector128<short> TransposeOdd (Vector128<short> left, Vector128<short> right) => { throw null };
public static Vector128<int> TransposeOdd (Vector128<int> left, Vector128<int> right) => { throw null };
public static Vector128<long> TransposeOdd (Vector128<long> left, Vector128<long> right) => { throw null };
public static Vector128<byte> TransposeOdd (Vector128<byte> left, Vector128<byte> right) => { throw null };
public static Vector128<ushort> TransposeOdd (Vector128<ushort> left, Vector128<ushort> right) => { throw null };
public static Vector128<uint> TransposeOdd (Vector128<uint> left, Vector128<uint> right) => { throw null };
public static Vector128<ulong> TransposeOdd (Vector128<ulong> left, Vector128<ulong> right) => { throw null };
public static Vector128<float> TransposeOdd (Vector128<float> left, Vector128<float> right) => { throw null };
public static Vector128<double> TransposeOdd (Vector128<double> left, Vector128<double> right) => { throw null };
}
}
}cc @tannergooding @CarolEidt @echesakovMSFT
Activity
tannergooding commentedon Oct 28, 2019
Thanks @TamarChristinaArm.
I've added this to the list of APIs to cover tomorrow.
terrajobst commentedon Mar 3, 2020
Video
ShiftLeftLogicalAndInsertunderArmBaseshould move underAdvSimd, but is it 32 bit or 64 bit?API
tannergooding commentedon Mar 9, 2020
@TamarChristinaArm, looking at the encoding + decoding for
VSLI, it seems to imply thatL=1is valid and thereforeesizeis allowed to be 64, so this applies to ARM32 as well. Is that your understanding?Specifically, the
Applies when !(imm6 == 000xxx && L == 0) && Q = ?is stating it applies to everything butL:imm6 == 0000xxx, which is then reiterated in theDecode for all variants of this encoding.TamarChristinaArm commentedon Mar 10, 2020
@tannergooding Yeah I believe that's correct, I had missed the
!the first time around.TamarChristinaArm commentedon Apr 15, 2020
@tannergooding @echesakovMSFT I'm wondering about the
LeftLogicalAndInsert. Theshiftelement needs to be a compile time constant. Any idea how I should handle that?tannergooding commentedon Apr 15, 2020
Non constant inputs are handled by dropping back to a call which contains a jump table handling all possible cases (which is between 1 and 256), its part of the reason the APIs are recursive.
Intrinsics which take a 8-bit immediate are marked as
HW_Category_IMM. There are then some special modifier flags that indicate how it is handled in codegen:HW_Flag_MaybeIMM- Indicates there is another overload which isn'tHW_Category_IMMHW_Flag_NoJmpTableIMM- Indicates that a jump table fallback isn't necessaryHW_Flag_FullRangeIMM- Indicates that the jump table fallback covers all 256 possible casesThe important methods for importation are then:
HW_Category_IMMand if it isHW_Flag_MaybeIMMif the correspondingoperandisTYP_INTHW_Category_IMMwhere it is notHW_Flag_FullRangeIMMHW_Category_IMMwhere it is notHW_Flag_FullRangeIMMThe importation logic currently assumes the "immediate" is the last operand in the list: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/jit/hwintrinsic.cpp#L648. It then uses the above methods to determine how to handle things. This includes things like directly expanding the relevant intrinsic, generating an equivalent intrinsic fallback, or falling back to a method call. If it falls back to the method call it will see the method is recursively calling itself and force expansion and the node will carry a non-constant input through to codegen. It will also insert the relevant range check if one is needed.
An example of how this is handled in codegen for x86 is here: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp#L227-L254.
Once we get to codegen if it is a constant, we can just emit the instruction. If it isn't, we call genHWIntrinsicJumpTableFallback which emits the necessary jump table.
tannergooding commentedon Apr 15, 2020
This ultimately allows things like reflection or debugging to "just work" and the expectation is users won't use it in actual perf-critical paths. Users are expected to be profiling this code so they should catch the issue relatively quickly if one does exist.
There are a few cases that this won't catch (of inputs that the JIT will eventually determine to be constant but which aren't "constant" during importation) and we have an issue tracking improving that: #9989 and #11062. Ideally we would delay the decision to be a "fallback method call" until later in the pipeline (such as
lowering).We already have some support for doing that with existing
GT_INTRINSICnodes and we do it inRationalization: #11062 (comment), but expanding it forGT_HWINTRINSICnodes is a bit tougher and hasn't been done yet.TamarChristinaArm commentedon Apr 15, 2020
Awesome thanks, I'll get on those then :)
echesakov commentedon Apr 15, 2020
@TamarChristinaArm I am working at the moment on supporting intrinsic immediate operands on arm64 - I needed this for Extract, Insert and ExtractVector64/128 intrinsics - will have a PR soon
TamarChristinaArm commentedon Apr 15, 2020
@echesakovMSFT Ah great, I'll do the single register TBL in the mean time then.
tannergooding commentedon Apr 16, 2020
The following APIs are yet to be implemented:
TamarChristinaArm commentedon Apr 27, 2020
@echesakovMSFT I see
Extractcommitted. Are the pre-requites I need for this in now then?echesakov commentedon Apr 27, 2020
@TamarChristinaArm Yes, I think so.
TamarChristinaArm commentedon Apr 30, 2020
@tannergooding @echesakovMSFT I believe we need to move the entries in
ArmBasetoAdvSimdright? This PR was created before we discussed this with other intrinsics.tannergooding commentedon Apr 30, 2020
Yes, I believe so as
VSRIrequires "Enabling Advanced SIMD and floating-point support", which may not always be possible.TamarChristinaArm commentedon May 1, 2020
@echesakovMSFT the comment in
BuildHWIntrinsiconmayNeedBranchTargetRegconfuses me. I'm trying to understand what it's going to do if you pass a non-const immediate to an intrinsics that has no non-const immediate variant. The comment seems to indicate it'll allocate an extra register.. but don't understand why or what it's trying to do?echesakov commentedon May 1, 2020
@TamarChristinaArm If you pass a non-const immediate operand and the instruction does not have non-const form (i.e. does not accept a register operand instead of the immediate operand; I can't think about an instruction on Arm64 that has such fallback but I believe it was a case on x64 for many instructions - look for intrinsics marked as HW_Flag_MaybeIMM in hwintrinsiclistxarch.h) JIT still needs to be able to compile an intrinsic so it generates a "switch" table that conceptually does this:
For example, for ExtractVector128(Vector128<byte>) the code will look as follows
This requires allocating of x1 as a branch target.
However, for cases when immediate is 0 or 1 (e.g. ExtractVector128(Vector128<double>) we can branch with cbnz and don't need to allocate the additional register as in the following example:
In your case, (i.e. sri and sli) you will need to mark an intrinsic with HW_Category_IMM, compute an upper bound for immediate operand in HWIntrinsicInfo::lookupImmUpperBound() and add two case in the switch in LinearScan::BuildHWIntrinsic that will set
needBranchTargetReg = !intrin.op3->isContainedIntOrIImmed();echesakov commentedon May 1, 2020
@TamarChristinaArm I hope my explanation helped. If not - I would value any feedback how I can re-phrase this comment to make it more clear. Also feel free to ping me offline if you want to chat more about this.
TamarChristinaArm commentedon May 4, 2020
@echesakovMSFT It did!, I hadn't realized the JIT was emitting a runtime dispatch for this case, which makes sense, that's where my initial confusion came from :) Thanks for the explanation!
echesakov commentedon May 6, 2020
@TamarChristinaArm since you are working on this - I have assigned the issue to you.