Add gtGetOp2IfPresent()
It was noticed that many uses of gtGetOp2() fully expect op2 to
exist and be non-nullptr, and the use of gtGetOp2() was simply
for style/readability purposes. However, it has a cost, as it
checks whether the tree is binary first, and returns nullptr if
not. For most cases, this is unecessary and expensive.
Introduce a new gtGetOp2IfPresent() function that captures the
previous behavior: checking if the tree node is binary before
returning op2, or returning nullptr otherwise. gtGetOp2() is
changed to simply return gtOp2 directly, without any checking
in non-DEBUG builds. It can be used if you know the op2 exists.
Most uses of gtGetOp2() were left alone (and hence get the new
behavior). The ones that need the old behavior were renamed
gtGetOp2IfPresent().
Mostly newer code is affected, as older code would generally
access gtOp2 directly, whereas newer code started using gtGetOp2()
for style and symmetry, especially after gtGetOp1() was introduced.
Commit migrated from https://github.com/dotnet/coreclr/commit/
8ed2c04cb49593a6b582c0f1a96c3a67da36dfab