[release/5.0-rc2] Fix for folding of *(typ*)&lclVar for small types #41838
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Backport of #40871 to release/5.0-rc2
Customer Impact
The underlying issue was discovered during one of libraries-jitstress test runs after #40535 was merged. After thorough analysis I could reproduce the issue without any stress mode by simple marking one of the function in libraries with
AggressiveInliningattribute.Later, I constructed a simple C# test case (see src/tests/JIT/Regression/JitBlue/Runtime_40607/Runtime_40607.cs)
Here the result of
DependsOnUnInitValuedepends on uninitialized value of stack local variableshouldBeFalse, even though it's clear from the program that it should always hasfalsevalue.Such issue can be reproduced when first loading of such local would be mophed earlier than its first store. The test case mentioned above is generalized for other small types (see src/tests/JIT/Regression/JitBlue/Runtime_40607/Runtime_40607.il)
This PR fixes an issue in a slightly different way than #40535 and, as mentioned in #40871 (comment), remedies most of performance regression introduced by #40253
Testing
I completed jitstress test runs with coreclr and libraries tests.
Risk
Low to moderate.
@dotnet/jit-contrib