diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 866cd170dd2356..8372fd0959be10 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -7656,7 +7656,10 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre const unsigned expectedSize = genTypeSize(parentNode->TypeGet()) / 2; const unsigned operandSize = genTypeSize(childNode->TypeGet()); - supportsGeneralLoads = supportsUnalignedSIMDLoads && (operandSize >= expectedSize); + // For broadcasts we can only optimize constants and memory operands + const bool broadcastIsContainable = childNode->OperIsConst() || childNode->isMemoryOp(); + supportsGeneralLoads = + broadcastIsContainable && supportsUnalignedSIMDLoads && (operandSize >= expectedSize); break; } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.cs b/src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.cs new file mode 100644 index 00000000000000..ce2881a9d67185 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using Xunit; + +public class Runtime_90508 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector128 Test1(Vector128 v, double b) => + v + Sse3.MoveAndDuplicate(Vector128.CreateScalarUnsafe(b)); + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector128 Test2(Vector128 v) => + v + Sse3.MoveAndDuplicate(Vector128.CreateScalarUnsafe(1.0)); + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector128 Test3(Vector128 v) => + v + Sse3.MoveAndDuplicate(Vector128.Create(1.0)); + + [Fact] + public static int TestEntryPoint() + { + if (!Sse3.IsSupported) + { + return 100; + } + + if (Test1(Vector128.Create(42.0), 1).ToString().Equals("<43, 43>") && + Test2(Vector128.Create(42.0)).ToString().Equals("<43, 43>") && + Test3(Vector128.Create(42.0)).ToString().Equals("<43, 43>")) + { + return 100; + } + return 101; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.csproj new file mode 100644 index 00000000000000..15edd99711a1a4 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.csproj @@ -0,0 +1,8 @@ + + + True + + + + + \ No newline at end of file