When fgMorphField processes a static field for which eeGetRelocTypeHint returns IMAGE_REL_BASED_REL32, it creates an GT_IND over an IntCon rather than a GT_CLSVAR. Value numbering has processing to disambiguate static fields represented as ClsVars, but not the others, despite the others being annotated with the symbolic field information.
Here's some code that shows the issue; there are logs of redundant m_arr accesses that don't get CSE'd because of this. Note that they get CSE'd with crossgen, where eeGetRelocTypeHint doesn't return IMAGE_REL_BASED_REL32, just not with CoreRun.
using System;
using System.Diagnostics;
class ArrayPerf
{
private static int[] m_arr;
private const int MAX_ARRAY_SIZE = 4096;
private static readonly int DIM_1 = MAX_ARRAY_SIZE;
static void Main(string[] args)
{
long iterations = Int64.Parse(args[0]);
int value;
m_arr = new int[DIM_1];
for (int i = 0; i < DIM_1; i++)
m_arr[i] = i;
for (int j = 0; j < DIM_1; j++)
value = m_arr[j];
//var sw = Stopwatch.StartNew();
for (long i = 0; i < iterations; i++)
{
for (int j = 0; j < DIM_1; j++)
{
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
}
}
//sw.Stop();
//Console.WriteLine(sw.ElapsedMilliseconds);
}
}
dotnet/coreclr#6889 is already in flight to address this, just filing this issue for tracking and to be able to reference it for further issues optimizing the same code.
category:cq
theme:value-numbering
skill-level:expert
cost:small
When
fgMorphFieldprocesses a static field for whicheeGetRelocTypeHintreturnsIMAGE_REL_BASED_REL32, it creates anGT_INDover anIntConrather than aGT_CLSVAR. Value numbering has processing to disambiguate static fields represented asClsVars, but not the others, despite the others being annotated with the symbolic field information.Here's some code that shows the issue; there are logs of redundant
m_arraccesses that don't get CSE'd because of this. Note that they get CSE'd with crossgen, whereeeGetRelocTypeHintdoesn't returnIMAGE_REL_BASED_REL32, just not withCoreRun.dotnet/coreclr#6889 is already in flight to address this, just filing this issue for tracking and to be able to reference it for further issues optimizing the same code.
category:cq
theme:value-numbering
skill-level:expert
cost:small