Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Fold overflow operations in value numbering" (second attempt after r…
…evert) (#51440) * Added a missing license header * Added a test verifying that checked arithmetic is correct * Added a test verifying that checked casts are correct * Disabled the test for checked casts on Mono * Refactored VNEvalShouldFold * Refactored gtFoldExprConst to use helpers and follow the common code style * Fixed the comment stating TYP_BYREF has no zero value * Moved checking of overflow for arithmetic operations from gtFoldExprConst into a separate namespace * Implemented folding of overflow arithmetic in value numbering * Fixed some typos in valuenum.cpp/h * Added identity-based evaluation for overflow arithmetic * Made the definition of var_types a standalone header so that it can be safely #included'ed in utils.h * Refactored gtFoldExpr some more, moved the overflow checking logic to CheckedOps, implemented overflow checking for floating point -> integer casts * Implemented folding of checked casts in value numbering * Demote the tests to Tier1 They throw and catch quite a few exceptions. * Fixed a comment UINT32 -> UINT64 * Made arithmetic CheckedOps functions templated Reduces code duplication and obviates the need for some conditions and casts. They use the implementation from the Long* variants of the old functions, except for "SubOverflows", where some instantiations, unreachable at runtime, were using "size_t" as the type argument and causing warnings. The relevant part of "AddOverflows" has been inlined into "SubOverflows". * Move the locals under "if" to avoid shadowing * Use ClrSafeInt instead of custom code * Fix a copy and paste mistake Co-authored-by: Anton Lapounov <anton.lapounov@microsoft.com> * Update src/coreclr/jit/utils.cpp * Apply suggestions from code review Co-authored-by: Anton Lapounov <anton.lapounov@microsoft.com> * Assert type != TYP_BYREF in VNEvalShouldFold The method is not prepared to handle them. Also add a note about that to the header. Also delete TODO-Review about it. Right now the only caller of VNEvalShouldFold guards against TYP_BYREF folding, so this assert is a safety measure against future callers not taking byrefs into account. * Drop the MAX_ prefix from MIN Co-authored-by: Anton Lapounov <anton.lapounov@microsoft.com>
- Loading branch information