コード例 #1
0
        public static bool Equal(Vector128 <float> vector1, Vector128 <float> vector2)
        {
            // This implementation is based on the DirectX Math Library XMVector4Equal method
            // https://github.com/microsoft/DirectXMath/blob/master/Inc/DirectXMathVector.inl

            if (AdvSimd.Arm64.IsSupported)
            {
                Vector128 <uint> vResult = AdvSimd.CompareEqual(vector1, vector2).AsUInt32();

                Vector64 <byte> vResult0 = vResult.GetLower().AsByte();
                Vector64 <byte> vResult1 = vResult.GetUpper().AsByte();

                Vector64 <byte> vTemp10 = AdvSimd.Arm64.ZipLow(vResult0, vResult1);
                Vector64 <byte> vTemp11 = AdvSimd.Arm64.ZipHigh(vResult0, vResult1);

                Vector64 <ushort> vTemp21 = AdvSimd.Arm64.ZipHigh(vTemp10.AsUInt16(), vTemp11.AsUInt16());
                return(vTemp21.AsUInt32().GetElement(1) == 0xFFFFFFFF);
            }
            else if (Sse.IsSupported)
            {
                return(Sse.MoveMask(Sse.CompareNotEqual(vector1, vector2)) == 0);
            }
            else
            {
                // Redundant test so we won't prejit remainder of this method on platforms without AdvSimd.
                throw new PlatformNotSupportedException();
            }
        }