Skip to content

Commit

Permalink
[release/8.0-staging] Fix hwintrinsicChild->isContained() assert (#96388
Browse files Browse the repository at this point in the history
)

* Fix containment

* Fix naming

* Update src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.cs

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>

* better fix

* oops, typo

* clean up

* Update lowerxarch.cpp

* Update Runtime_90508.cs

* Update Runtime_90508.cs

---------

Co-authored-by: EgorBo <egorbo@gmail.com>
Co-authored-by: Bruce Forstall <brucefo@microsoft.com>
  • Loading branch information
3 people authored Jan 13, 2024
1 parent 46adbbb commit 9d77190
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7668,7 +7668,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;
}

Expand Down
39 changes: 39 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_90508/Runtime_90508.cs
Original file line number Diff line number Diff line change
@@ -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<double> Test1(Vector128<double> v, double b) =>
v + Sse3.MoveAndDuplicate(Vector128.CreateScalarUnsafe(b));

[MethodImpl(MethodImplOptions.NoInlining)]
private static Vector128<double> Test2(Vector128<double> v) =>
v + Sse3.MoveAndDuplicate(Vector128.CreateScalarUnsafe(1.0));

[MethodImpl(MethodImplOptions.NoInlining)]
private static Vector128<double> Test3(Vector128<double> 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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 9d77190

Please sign in to comment.