Skip to content

Commit bb32921

Browse files
Fix hwintrinsicChild->isContained() assert (#90556)
Co-authored-by: Bruce Forstall <[email protected]>
1 parent 8de93fc commit bb32921

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/coreclr/jit/lowerxarch.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7656,7 +7656,10 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre
76567656
const unsigned expectedSize = genTypeSize(parentNode->TypeGet()) / 2;
76577657
const unsigned operandSize = genTypeSize(childNode->TypeGet());
76587658

7659-
supportsGeneralLoads = supportsUnalignedSIMDLoads && (operandSize >= expectedSize);
7659+
// For broadcasts we can only optimize constants and memory operands
7660+
const bool broadcastIsContainable = childNode->OperIsConst() || childNode->isMemoryOp();
7661+
supportsGeneralLoads =
7662+
broadcastIsContainable && supportsUnalignedSIMDLoads && (operandSize >= expectedSize);
76607663
break;
76617664
}
76627665

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Runtime.CompilerServices;
5+
using System.Runtime.Intrinsics;
6+
using System.Runtime.Intrinsics.X86;
7+
using Xunit;
8+
9+
public class Runtime_90508
10+
{
11+
[MethodImpl(MethodImplOptions.NoInlining)]
12+
private static Vector128<double> Test1(Vector128<double> v, double b) =>
13+
v + Sse3.MoveAndDuplicate(Vector128.CreateScalarUnsafe(b));
14+
15+
[MethodImpl(MethodImplOptions.NoInlining)]
16+
private static Vector128<double> Test2(Vector128<double> v) =>
17+
v + Sse3.MoveAndDuplicate(Vector128.CreateScalarUnsafe(1.0));
18+
19+
[MethodImpl(MethodImplOptions.NoInlining)]
20+
private static Vector128<double> Test3(Vector128<double> v) =>
21+
v + Sse3.MoveAndDuplicate(Vector128.Create(1.0));
22+
23+
[Fact]
24+
public static int TestEntryPoint()
25+
{
26+
if (!Sse3.IsSupported)
27+
{
28+
return 100;
29+
}
30+
31+
if (Test1(Vector128.Create(42.0), 1).ToString().Equals("<43, 43>") &&
32+
Test2(Vector128.Create(42.0)).ToString().Equals("<43, 43>") &&
33+
Test3(Vector128.Create(42.0)).ToString().Equals("<43, 43>"))
34+
{
35+
return 100;
36+
}
37+
return 101;
38+
}
39+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)