Skip to content

Commit 67993d0

Browse files
authored
JIT: Avoid removing CSE candidates in fgMorphExpandCast (#106691)
Fix #106609
1 parent 2831f11 commit 67993d0

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

src/coreclr/jit/morph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ GenTree* Compiler::fgMorphExpandCast(GenTreeCast* tree)
451451
// Because there is no IL instruction conv.r4.un, uint/ulong -> float
452452
// casts are always imported as CAST(float <- CAST(double <- uint/ulong)).
453453
// We can eliminate the redundant intermediate cast as an optimization.
454-
else if ((dstType == TYP_FLOAT) && (srcType == TYP_DOUBLE) && oper->OperIs(GT_CAST)
454+
else if ((dstType == TYP_FLOAT) && (srcType == TYP_DOUBLE) && oper->OperIs(GT_CAST) &&
455+
!gtIsActiveCSE_Candidate(tree)
455456
#ifdef TARGET_ARM
456457
&& !varTypeIsLong(oper->AsCast()->CastOp())
457458
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
// Generated by Fuzzlyn v2.2 on 2024-08-17 17:16:59
5+
// Run on Arm64 Windows
6+
// Seed: 18124298882625099135-vectort,vector64,vector128,armadvsimd,armadvsimdarm64,armaes,armarmbase,armarmbasearm64,armcrc32,armcrc32arm64,armdp,armsha1,armsha256
7+
// Reduced from 129.5 KiB to 0.4 KiB in 00:04:55
8+
// Hits JIT assert in Release:
9+
// Assertion failed 'link' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Optimize Valnum CSEs' (IL size 39; hash 0xade6b36b; FullOpts)
10+
//
11+
// File: D:\a\_work\1\s\src\coreclr\jit\optcse.cpp Line: 5295
12+
//
13+
using System.Runtime.CompilerServices;
14+
using System.Runtime.Intrinsics;
15+
using System.Runtime.Intrinsics.Arm;
16+
using Xunit;
17+
18+
public class Runtime_106609
19+
{
20+
[Fact]
21+
public static void TestEntrypoint()
22+
{
23+
if (AdvSimd.IsSupported)
24+
{
25+
try
26+
{
27+
Test();
28+
}
29+
catch
30+
{
31+
}
32+
}
33+
}
34+
35+
public static float[] s_2;
36+
[MethodImpl(MethodImplOptions.NoInlining)]
37+
private static void Test()
38+
{
39+
for (int vr8 = 0; vr8 < 2; vr8++)
40+
{
41+
var vr9 = Vector64.Create<uint>(0);
42+
s_2[0] = (float)(-(-(double)AdvSimd.Extract(vr9, 0)));
43+
}
44+
}
45+
}
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)