-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
dotnet/coreclr
#17637Closed
Copy link
Milestone
Description
I was trying the new X86 intrinsics and noticed that when casting a signed type extracted from a vector to a larger signed type, the value is not sign-extended, it is zero-extended.
The following program demonstrates the issue:
using System;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
namespace SseTest
{
class Program
{
static void Main(string[] args)
{
Vector128<short> test = Sse2.SetVector128(0, 0, 0, 0, 0, 0, 0, -1);
Console.WriteLine(ExtractShortLow(test));
Console.WriteLine(ExtractShortLow2(test));
}
private static int ExtractShortLow(Vector128<short> Vector)
{
return Sse2.Extract(Vector, 0);
}
private static int ExtractShortLow2(Vector128<short> Vector)
{
short tmp = Sse2.Extract(Vector, 0);
return tmp;
}
}
}On debug mode, the output is:
65535
-1
On release, it is:
65535
65535
The expected output is:
-1
-1
dotnet version: 2.1.300-rc1-008673.
Sorry if it was already reported elsewhere.
Edit: The issue also happens with sbyte, but not with int -> long.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels