diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 99227ce03469f..2a97fd82bb7ae 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -11028,7 +11028,16 @@ GenTree* Compiler::fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node) } } - if (lhs == nullptr || rhs == nullptr) + if ((lhs == nullptr) || (rhs == nullptr)) + { + break; + } + + // Filter out side effecting cases for several reasons: + // 1. gtNewSimdBinOpNode may swap operand order. + // 2. The code above will swap operand order. + // 3. The code above does not handle GTF_REVERSE_OPS. + if (((lhs->gtFlags | rhs->gtFlags) & GTF_ALL_EFFECT) != 0) { break; } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.cs b/src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.cs new file mode 100644 index 0000000000000..6990d188b488c --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license.aa + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using Xunit; + +public class Runitme_91855 +{ + [Fact] + public static void TestEntryPoint() + { + Assert.Throws(() => Foo(null, 0)); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector128 Foo(C c, uint val) + { + return Vector128.Create(100u / val) & (c.V ^ Vector128.AllBitsSet); + } + + private class C + { + public Vector128 V; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.csproj new file mode 100644 index 0000000000000..de6d5e08882e8 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.csproj @@ -0,0 +1,8 @@ + + + True + + + + +