JIT: change basic block weight to float (#45052)
authorAndy Ayers <andya@microsoft.com>
Tue, 24 Nov 2020 22:25:04 +0000 (14:25 -0800)
committerGitHub <noreply@github.com>
Tue, 24 Nov 2020 22:25:04 +0000 (14:25 -0800)
commit703145649baf152e3678825be1849f6fd1bd2b24
tree1166e6fb1119df7c9be8a8a7cc821a219905163f
parent62f55e140898b350d3cdb06e6032798976710cee
JIT: change basic block weight to float (#45052)

Change the core data type for basic block weights from unsigned to float,
to simplify overall calculations and allow for a wider dynamic range.

Many changes are straightforward, but a few are worth noting:
* LSRA needs a true max weight, so had to introduce infinity
* I removed some of the overflow checking as floats naturally saturate.
* The simple geometric loop weight scaling (*8 per loop nest level) leads
  to some very large counts in some tests (15 level loop nests). We may
  want to rethink this and scale less aggressively in deep nests.
* Morph's use of the weighted ref counts for RCS_EARLY is nonstandard
  and the values are not actually weights, so I just added a cast back to unsigned.
* Several places in the jit seem to try and compare or combine unweighted
  and weighted counts; I don't think this makes sense. But have left as is.
* Lower, LIR, and Decompose were passing around weights but never using them.
* I had to introduce a special new weight for the inline projection we do
  for the prejit root.

These changes lead to small numbers of diffs, mostly places where small rounding
changes have altered heuristics; notably:
* cse weights
* LSRA's initial take on whether a parameter should be enregistered

Overall diff impact is a wash.

There are almost no diffs without PGO/IBC data. Diffs are slightly more
prominent in the Roslyn assemblies prejitted with some IBC.

I've tried to keep the format of weights the same in dumps (in most places)
and see minimal diffs in dumps too.
24 files changed:
src/coreclr/src/jit/assertionprop.cpp
src/coreclr/src/jit/block.h
src/coreclr/src/jit/codegencommon.cpp
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/compiler.hpp
src/coreclr/src/jit/decomposelongs.cpp
src/coreclr/src/jit/decomposelongs.h
src/coreclr/src/jit/emit.cpp
src/coreclr/src/jit/flowgraph.cpp
src/coreclr/src/jit/importer.cpp
src/coreclr/src/jit/lclvars.cpp
src/coreclr/src/jit/lir.cpp
src/coreclr/src/jit/lir.h
src/coreclr/src/jit/liveness.cpp
src/coreclr/src/jit/lower.cpp
src/coreclr/src/jit/lower.h
src/coreclr/src/jit/lsra.cpp
src/coreclr/src/jit/lsra.h
src/coreclr/src/jit/morph.cpp
src/coreclr/src/jit/optcse.cpp
src/coreclr/src/jit/optimizer.cpp
src/coreclr/src/jit/regalloc.cpp
src/coreclr/src/jit/utils.cpp
src/coreclr/src/jit/utils.h