Skip to content

Commit 1bb92c6

Browse files
testcase for RAW mask byte
1 parent 3faf84f commit 1bb92c6

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Numerics;
6+
using System.Runtime.CompilerServices;
7+
using System.Runtime.Intrinsics;
8+
using System.Runtime.Intrinsics.Arm;
9+
using Xunit;
10+
11+
namespace JIT.HardwareIntrinsics.Arm._Sve2
12+
{
13+
public static partial class Program
14+
{
15+
[Fact]
16+
public static unsafe void CreateWhileReadAfterWriteMaskByte_SameAddress()
17+
{
18+
if (!Sve2.IsSupported)
19+
{
20+
return;
21+
}
22+
23+
// When pointers are idential, all elements of returned mask are "1"
24+
byte* ptr = stackalloc byte[Vector<byte>.Count];
25+
Vector<byte> mask = Sve2.CreateWhileReadAfterWriteMaskByte(ptr, ptr);
26+
27+
for (int i = 0; i < Vector<byte>.Count; i++)
28+
{
29+
if (mask.GetElement(i) == 0)
30+
{
31+
throw new Exception(
32+
$"CreateWhileReadAfterWriteMaskByte(ptr, ptr): Expected all elements true, but element {i} was false.");
33+
}
34+
}
35+
}
36+
37+
[Fact]
38+
public static unsafe void CreateWhileReadAfterWriteMaskByte_OffsetByOne()
39+
{
40+
if (!Sve2.IsSupported)
41+
{
42+
return;
43+
}
44+
45+
// When pointers differ by one element, first element of returned mask is "1", the rest are "0"
46+
byte* ptr = stackalloc byte[Vector<byte>.Count + 1];
47+
Vector<byte> mask = Sve2.CreateWhileReadAfterWriteMaskByte(ptr, ptr + 1);
48+
49+
if (mask.GetElement(0) == 0)
50+
{
51+
throw new Exception(
52+
$"CreateWhileReadAfterWriteMaskByte(ptr, ptr+1): Expected element 0 to be true, but was false.");
53+
}
54+
55+
for (int i = 1; i < Vector<byte>.Count; i++)
56+
{
57+
if (mask.GetElement(i) != 0)
58+
{
59+
throw new Exception(
60+
$"CreateWhileReadAfterWriteMaskByte(ptr, ptr+1): Expected element {i} to be false, but was true.");
61+
}
62+
}
63+
}
64+
}
65+
}

src/tests/JIT/HardwareIntrinsics/Arm/Sve2/Sve2_r.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<Compile Include="Program.Sve2.cs" />
11+
<Compile Include="CreateWhileRWMask.cs" />
1112
<Compile Include="..\Shared\Helpers.cs" />
1213
<Compile Include="..\Shared\Program.cs" />
1314
<Compile Include="$(RepoRoot)src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.cs" />

src/tests/JIT/HardwareIntrinsics/Arm/Sve2/Sve2_ro.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<Compile Include="Program.Sve2.cs" />
11+
<Compile Include="CreateWhileRWMask.cs" />
1112
<Compile Include="..\Shared\Helpers.cs" />
1213
<Compile Include="..\Shared\Program.cs" />
1314
<Compile Include="$(RepoRoot)src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.cs" />

0 commit comments

Comments
 (0)