Skip to content

Commit dfb2850

Browse files
Remove some uses of dynamic from HardwareIntrinsic test code (#118273)
This is preventing the AdvSimd tests from running in NativeAOT contexts. Fixes #118234
1 parent d9be719 commit dfb2850

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/AdvSimd_r.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4-
<!-- https://github.com/dotnet/runtime/issues/118234 -->
5-
<NativeAotIncompatible>true</NativeAotIncompatible>
64
</PropertyGroup>
75
<PropertyGroup>
86
<DebugType>Embedded</DebugType>

src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/AdvSimd_ro.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4-
<!-- https://github.com/dotnet/runtime/issues/118234 -->
5-
<NativeAotIncompatible>true</NativeAotIncompatible>
64
</PropertyGroup>
75
<PropertyGroup>
86
<DebugType>Embedded</DebugType>

src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7789,35 +7789,33 @@ public static W MultiplyAddWidening<W, N>(W op1, N op2, N op3)
77897789
where W : IBinaryInteger<W>
77907790
where N : IBinaryInteger<N>
77917791
{
7792-
dynamic a = op2;
7793-
dynamic b = op3;
7794-
W product = (W)((W)a * (W)b);
7795-
W r = (W)(op1 + product);
7796-
return r;
7792+
W a = W.CreateChecked(op2);
7793+
W b = W.CreateChecked(op3);
7794+
W product = W.CreateTruncating(a * b);
7795+
return W.CreateTruncating(op1 + product);
77977796
}
77987797

77997798
public static W MultiplySubtractWidening<W, N>(W op1, N op2, N op3)
78007799
where W : IBinaryInteger<W>
78017800
where N : IBinaryInteger<N>
78027801
{
7803-
dynamic a = op2;
7804-
dynamic b = op3;
7805-
W product = (W)((W)a * (W)b);
7806-
W r = (W)(op1 - product);
7807-
return r;
7802+
W a = W.CreateChecked(op2);
7803+
W b = W.CreateChecked(op3);
7804+
W product = W.CreateTruncating(a * b);
7805+
return W.CreateTruncating(op1 - product);
78087806
}
78097807

78107808
public static N AddRoundedHighNarrowing<W, N>(W op1, W op2)
78117809
where W : IBinaryInteger<W>
78127810
where N : IBinaryInteger<N>
78137811
{
78147812
int halfsize = default(N).GetByteCount() * 8;
7815-
dynamic a = op1;
7816-
dynamic b = op2;
7817-
ulong sum = (ulong)a + (ulong)b;
7813+
ulong a = ulong.CreateChecked(op1);
7814+
ulong b = ulong.CreateChecked(op2);
7815+
ulong sum = a + b;
78187816
ulong bias = 1UL << (halfsize - 1);
7819-
dynamic result = sum + bias;
7820-
return (N)(result >> halfsize);
7817+
ulong result = (sum + bias) >> halfsize;
7818+
return N.CreateTruncating(result);
78217819
}
78227820

78237821
public static N AddRoundedHighNarrowingEven<W, N>(W op1, W op2, int i)
@@ -7839,12 +7837,12 @@ public static N SubtractRoundedHighNarrowing<W, N>(W op1, W op2)
78397837
where N : IBinaryInteger<N>
78407838
{
78417839
int halfsize = default(N).GetByteCount() * 8;
7842-
dynamic a = op1;
7843-
dynamic b = op2;
7840+
ulong a = ulong.CreateChecked(op1);
7841+
ulong b = ulong.CreateChecked(op2);
78447842
ulong sum = (ulong)a - (ulong)b;
78457843
ulong bias = 1UL << (halfsize - 1);
7846-
dynamic result = sum + bias;
7847-
return (N)(result >> halfsize);
7844+
ulong result = (sum + bias) >> halfsize;
7845+
return N.CreateTruncating(result);
78487846
}
78497847

78507848
public static N SubtractRoundedHighNarrowingEven<W, N>(W op1, W op2, int i)

0 commit comments

Comments
 (0)