Do not recost and rethread trees inside `optRemoveRangeCheck` (#69895)
authorSingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Fri, 27 May 2022 18:33:44 +0000 (21:33 +0300)
committerGitHub <noreply@github.com>
Fri, 27 May 2022 18:33:44 +0000 (11:33 -0700)
commit1f303a13e74ed05a1e024a54e64af62a92533e0c
treec1105073c195a270c42c797d3b9b2f18a69137e5
parent70fd5dcf6c838ba762b85684a7ab28e9f8c59619
Do not recost and rethread trees inside `optRemoveRangeCheck` (#69895)

* Do not set order in "optRemoveRangeCheck"

All but one caller of the method (RangeCheck) already do so in
their "for (GenTree* node : stmt->TreeList())" loops, so it is
not necessary.

Additionally, re-threading the statement, when combined with
"gtSetEvalOrder", can have the consequence of redirecting said
loops, possibly causing them to miss some trees, which was
observed in early propagation when working on removing "GT_INDEX".

A few small diffs because we no longer recost when removing
range checks in loop cloning, which is generally not necessary
because cloning runs before the "global" costing is performed,
except there is one quirk in "gtSetEvalOrder" which was looking
as "compCurStmt", and that is not set during "fgSetBlockOrder".

* Work around a TP regression

Gets us back 0.13% (!!!) instructions according to PIN.
src/coreclr/jit/compiler.h
src/coreclr/jit/optimizer.cpp
src/coreclr/jit/rangecheck.cpp
src/coreclr/jit/rangecheck.h