Skip to content

Commit

Permalink
Workaround for incorrect codegen on .NET 5
Browse files Browse the repository at this point in the history
See Vector256.Create issue: dotnet/runtime#47236
  • Loading branch information
Sergio0694 committed Jan 20, 2021
1 parent 407c2d9 commit a7ca1b0
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Numerics;
using System.Runtime.CompilerServices;
#if SUPPORTS_RUNTIME_INTRINSICS
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
#endif
Expand Down Expand Up @@ -77,7 +78,14 @@ public Vector4 ConvolveCore(ref Vector4 rowStartRef)
float* bufferEnd = bufferStart + (this.Length & ~3);
Vector256<float> result256_0 = Vector256<float>.Zero;
Vector256<float> result256_1 = Vector256<float>.Zero;
var mask = Vector256.Create(0, 0, 0, 0, 1, 1, 1, 1);
ReadOnlySpan<byte> maskBytes = new byte[]
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 0,
};
Vector256<int> mask = Unsafe.ReadUnaligned<Vector256<int>>(ref MemoryMarshal.GetReference(maskBytes));

while (bufferStart < bufferEnd)
{
Expand Down

0 comments on commit a7ca1b0

Please sign in to comment.