Repository navigation
JIT: Value-numbering is over-conservative for image_rel32 statics #6552
Description
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
Activity
Fix IMGREL32 static field addr value-num blindspot
Fix IMGREL32 static field addr value-num blindspot
Fix IMGREL32 static field addr value-num blindspot
Fix IMGREL32 static field addr value-num blindspot
Fix IMGREL32 static field addr value-num blindspot
JosephTremoulet commentedon Sep 12, 2016
Fix was backed out in dotnet/coreclr#7118; reopening issue.
JosephTremoulet commentedon Sep 12, 2016
I believe we can re-apply the same fix (#6889) for this issue once dotnet/coreclr#7147 is fixed.
jakobbotsch commentedon Dec 15, 2022
We do CSE these today, so this seems fixed.