Repository navigation
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug
Milestone
Description
Reproduction:
using System;
using System.Runtime.CompilerServices;
Console.WriteLine(Problem(new() { Value = 1 }));
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static int Problem(StructWithIndex a)
{
bool k = a.Value == 1;
a = default;
if (k)
{
return 1;
}
return a.Index;
}
struct StructWithIndex
{
public int Index;
public int Value;
}Run with DOTNET_JitNoStructPromotion=1 and DOTNET_JitNoCSE=1.
Expected result: prints 1.
Actual result: prints 0.
Cause: the interference checks in the forward substitution algorithm use gtHasRef which does not pay attention to LCL_FLD nodes:
optRedundantRelop in BB01; jump tree is
N004 ( 5, 5) [000014] ------------ * JTRUE void
N003 ( 3, 3) [000013] J------N---- \--* EQ int $142
N001 ( 1, 1) [000011] ------------ +--* LCL_VAR int V02 tmp1 u:1 (last use) $141
N002 ( 1, 1) [000012] ------------ \--* CNS_INT int 0 $40
... checking previous tree
N003 ( 5, 4) [000008] IA------R--- * ASG struct (init) $VN.Void
N002 ( 3, 2) [000005] D------N---- +--* LCL_VAR struct<StructWithIndex, 8> V00 arg0 d:2
N001 ( 1, 1) [000007] ------------ \--* CNS_INT int 0 $40
-- prev tree VN is not related
... checking previous tree
N005 ( 8, 6) [000010] -A--G---R--- * ASG int $141
N004 ( 1, 1) [000009] D------N---- +--* LCL_VAR int V02 tmp1 d:1 $141
N003 ( 8, 6) [000004] ----G------- \--* EQ int $141
N001 ( 3, 4) [000002] ------------ +--* LCL_FLD int V00 arg0 u:1[+4] Fseq[Value] (last use) $140
N002 ( 1, 1) [000003] ------------ \--* CNS_INT int 1 $42
-- prev tree has relop with reversed liberal VN
-- prev tree is viable candidate for relop fwd sub!
-- done! new jump tree is
N004 ( 5, 5) [000014] ----G------- * JTRUE void
N003 ( 8, 6) [000021] J---G--N---- \--* NE int $142
N001 ( 3, 4) [000022] ------------ +--* LCL_FLD int V00 arg0 [+4] Fseq[Value] (last use) $140
N002 ( 1, 1) [000023] ------------ \--* CNS_INT int 1 $42Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug
Activity