Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that we don't try and optimize masks for promoted fields #110485

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/coreclr/jit/optimizemaskconversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,22 @@ class MaskConversionsCheckVisitor final : public GenTreeVisitor<MaskConversionsC
weight->InvalidateWeight();
return fgWalkResult::WALK_CONTINUE;
}

// Cannot convert any locals that r promoted struct fields
if (varDsc->lvIsStructField)
{
JITDUMP("is struct field. ");
weight->InvalidateWeight();
return fgWalkResult::WALK_CONTINUE;
}

// TODO: Converting to a mask loses data - as each field is only a single bit.
// For parameters, OSR locals, and locals which are used as vectors, then they
// cannot be stored as a mask as data will be lost.
// For all of these, conversions could be done by creating a new store of type mask.
// Then uses as mask could be converted to type mask and pointed to use the new
// definition. The weighting would need updating to take this into account.
else if (isLocalUse && !hasConversion)
if (isLocalUse && !hasConversion)
{
JITDUMP("is used as vector. ");
weight->InvalidateWeight();
Expand Down
91 changes: 91 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_110326/Runtime_110326.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using Xunit;

public class Runtime_110326A
{
public struct S1
{
public bool bool_2;
public Vector512<short> v512_short_3;
public Vector512<float> v512_float_4;
}

[Fact]
public static void TestEntryPoint()
{
Runtime_110326A.Method1();
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static ulong Method1()
{
S1 s1_s1_d1_f3_160 = new S1();
return Vector512.ExtractMostSignificantBits(s1_s1_d1_f3_160.v512_short_3);
}
}

public class Runtime_110326B
{
public struct S2_D1_F2
{
public struct S2_D2_F2
{
public Vector<double> v_double_0;
}

public struct S2_D2_F3
{
public Vector3 v3_10;
}
}

public struct S2_D1_F3
{
public struct S2_D2_F3
{
public Vector256<int> v256_int_14;
}

public Vector128<long> v128_long_13;
public Vector512<uint> v512_uint_16;
}

[Fact]
public static void TestEntryPoint()
{
Runtime_110326B.Method0();
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void Method0()
{
S2_D1_F2.S2_D2_F2 s2_s2_d1_f2_s2_d2_f2_262 = new S2_D1_F2.S2_D2_F2();
S2_D1_F2.S2_D2_F2 s2_s2_d1_f2_s2_d2_f2_263 = s2_s2_d1_f2_s2_d2_f2_262;
S2_D1_F2.S2_D2_F3 s2_s2_d1_f2_s2_d2_f3_264 = new S2_D1_F2.S2_D2_F3();
S2_D1_F2.S2_D2_F3 s2_s2_d1_f2_s2_d2_f3_265 = s2_s2_d1_f2_s2_d2_f3_264;
S2_D1_F2 s2_s2_d1_f2_266 = new S2_D1_F2();
S2_D1_F3.S2_D2_F3 s2_s2_d1_f3_s2_d2_f3_268 = new S2_D1_F3.S2_D2_F3();
S2_D1_F3 s2_s2_d1_f3_269 = new S2_D1_F3();
S2_D1_F3 s2_s2_d1_f3_270 = s2_s2_d1_f3_269;
s2_s2_d1_f3_270.v512_uint_16 = Vector512.IsZero(Vector512<uint>.AllBitsSet);

Log("s2_s2_d1_f", s2_s2_d1_f2_s2_d2_f2_262.v_double_0);
Log("s2_s2_d1_f", s2_s2_d1_f2_s2_d2_f2_263.v_double_0);
Log("s2_s2_d1_f", s2_s2_d1_f2_s2_d2_f3_264);
Log("s2_s2_d1_f", s2_s2_d1_f2_s2_d2_f3_265.v3_10);
Log("s2_s2_d1_f", s2_s2_d1_f2_266);
Log("s2_s2_d1_f", s2_s2_d1_f3_s2_d2_f3_268.v256_int_14);
Log("s2_s2_d1_f", s2_s2_d1_f3_269.v128_long_13);
Log("s2_s2_d1_f", s2_s2_d1_f3_270.v128_long_13);
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void Log(string varName, object varValue)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
<ItemGroup>
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="0" />
<CLRTestEnvironmentVariable Include="DOTNET_JitStress" Value="2" />
</ItemGroup>
</Project>
Loading