Skip to content

Mono's Vector128 support incorrectly handles Abs for signed integer MinValue #95592

@stephentoub

Description

@stephentoub

Repro:
#95588

        [Fact]
        public void Vector128SByteAbs_MinValue()
        {
            Vector128<sbyte> vector = Vector128.Create(sbyte.MinValue);
            Vector128<sbyte> abs = Vector128.Abs(vector);
            for (int index = 0; index < Vector128<sbyte>.Count; index++)
            {
                Assert.Equal(sbyte.MinValue, vector.GetElement(index));
            }
        }

This test passes on coreclr. On mono it fails with:

    System.Runtime.Intrinsics.Tests.Vectors.Vector128Tests.Vector128SByteAbs_MinValue [FAIL]
      System.OverflowException : Negating the minimum value of a twos complement number is invalid.
      Stack Trace:
        /_/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs(163,0): at System.Runtime.Intrinsics.Tests.Vectors.Vector128Tests.Vector128SByteAbs_MinValue()
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.Mono.cs(22,0): at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
        /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(57,0): at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

This is the source of the test failures in #94555 (comment).

cc: @radekdoulik, @tannergooding

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions