Fix lclvar "cloning" in const division lowering
authorMike Danes <onemihaid@hotmail.com>
Sat, 1 Dec 2018 13:35:55 +0000 (15:35 +0200)
committerMike Danes <onemihaid@hotmail.com>
Sat, 1 Dec 2018 13:35:55 +0000 (15:35 +0200)
commitc3919e330c3a753ab5cdec5ca5aee204d2da2f5c
treea853e5dfe8cd28cb7150bd141a8b282def361a27
parentd480065527475d3f038b20f76f1ba6b84f5a226f
Fix lclvar "cloning" in const division lowering

The existing code was creating new uses of existing variables using the type of the division operation instead of the type of the existing variable use. There is one rare case when this does not work properly:
* if the variable is "normalize on load" (that implies that it is also a small int type variable)
* and if the variable is previously assigned to such that a subrange assertion is generated
* and if morph decides not to insert the load normalization cast due to the subrange assertion
* and if the variable is not enregistered
Then the assignment stores 2 bytes to the stack location but the uses generated by the division lowering code read 4 bytes because they have TYP_INT.

Commit migrated from https://github.com/dotnet/coreclr/commit/b27167e3e89d51cc6901275eb68289631ae72aa4
src/coreclr/src/jit/lower.cpp
src/coreclr/src/jit/lower.h
src/coreclr/tests/src/JIT/Regression/JitBlue/Github_19558/Github_19558.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/Github_19558/Github_19558.csproj [new file with mode: 0644]