JIT: track memory loop dependence of trees during value numbering (#55936)
authorAndy Ayers <andya@microsoft.com>
Thu, 22 Jul 2021 01:03:38 +0000 (18:03 -0700)
committerGitHub <noreply@github.com>
Thu, 22 Jul 2021 01:03:38 +0000 (18:03 -0700)
commit1b4f786ec254a2974c8fafa1bde4361cdcf57d1d
treee198e024a6fad5211616d1f3c1fb1097fc446b02
parentcc7a8efb1849aef9e6bb98a0dcea3189ec0cf868
JIT: track memory loop dependence of trees during value numbering (#55936)

Leverage value numbering's alias analysis to annotate trees with the loop
memory dependence of the tree's value number.

First, refactor the `mapStore` value number so that it also tracks the loop
number where the store occurs. This is done via an extra non-value-num arg,
so add appropriate bypasses to logic in the jit that expect to only find
value number args. Also update the dumping to display the loop information.

Next, during VN computation, record loop memory dependence from `mapStores`
with the tree currently being value numbered, whenever a value number comes
from a particular map. There may be multiple such recording events per tree,
so add logic on the recording side to track the most constraining dependence.
Note value numbering happens in execution order, so there is an unambiguous
current tree being value numbered.

This dependence info is tracked via a side map.

Finally, during hoisting, for each potentially hoistable tree, consult the side
map to recover the loop memory dependence of a tree, and if that dependence is
at or within the loop that we're hoisting from, block the hoist.

I've also absorbed the former class var (static field) hosting exclusion into
this new logic. This gives us slightly more relaxed dependence in some cases.

Resolves #54118.
src/coreclr/jit/compiler.cpp
src/coreclr/jit/compiler.h
src/coreclr/jit/optimizer.cpp
src/coreclr/jit/valuenum.cpp
src/coreclr/jit/valuenumfuncs.h
src/tests/JIT/Regression/JitBlue/Runtime_54118/Runtime_54118.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_54118/Runtime_54118.csproj [new file with mode: 0644]