From d739e9be1812c586c8fc66c769c4413b6d0a7215 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 13 Jul 2020 17:46:22 -0700 Subject: [PATCH] Guard SseImpl method body with IsSupported check Though this method is only ever callable by code that's already done the right IsSupported check, add a redundant check to the method itself, so that when crossgenning SPC on non-xarch platforms we won't try and compile the xarch specific parts of this method. This should save some time and a bit of file size for non-xarch SPCs. See notes on #38894 for context. --- .../src/System/Numerics/Matrix4x4.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs index c13f7e8132ed22..0b0e92e9577200 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs @@ -1338,6 +1338,13 @@ public static unsafe bool Invert(Matrix4x4 matrix, out Matrix4x4 result) static unsafe bool SseImpl(Matrix4x4 matrix, out Matrix4x4 result) { + // Redundant test so we won't prejit remainder of this method + // on platforms without SSE. + if (!Sse.IsSupported) + { + throw new PlatformNotSupportedException(); + } + // This implementation is based on the DirectX Math Library XMMInverse method // https://github.com/microsoft/DirectXMath/blob/master/Inc/DirectXMathMatrix.inl