[mono][jit] Eliminate some type comparisons in gshared methods.#59543
Merged
Conversation
vargaz
requested review from
SamMonoRT,
imhameed and
lambdageek
as code owners
September 23, 2021 21:32
vargaz
force-pushed
the
type-eq-elim
branch
4 times, most recently
from
September 24, 2021 02:06
76ac8cf to
7a890b7
Compare
vargaz
force-pushed
the
type-eq-elim
branch
from
September 24, 2021 23:06
7a890b7 to
6b5f141
Compare
vargaz
marked this pull request as draft
September 25, 2021 22:39
vargaz
force-pushed
the
type-eq-elim
branch
2 times, most recently
from
September 26, 2021 01:13
6b5f141 to
4afc5fd
Compare
Contributor
Author
|
The failures are related. |
Contributor
Author
|
On a wasm aot hello world, this saves about 100k. |
vargaz
force-pushed
the
type-eq-elim
branch
5 times, most recently
from
September 27, 2021 11:44
f2d23e8 to
20b9c84
Compare
Comparisons of the form
```
internal static void ThrowForUnsupportedIntrinsicsVectorBaseType<T>() where T : struct
{
if (typeof(T) != typeof(byte) && typeof(T) != typeof(sbyte) &&
...
}
```
are very common in BCL code. They are compiled to:
```
IL_0001: ldtoken !!T
IL_0006: call [System.Runtime]System.Type [System.Runtime]System.Type::GetTypeFromHandle([System.Runtime]System.RuntimeTypeHandle)
IL_000b: ldtoken [System.Runtime]System.Byte
IL_0010: call [System.Runtime]System.Type [System.Runtime]System.Type::GetTypeFromHandle([System.Runtime]System.RuntimeTypeHandle)
IL_0015: call bool [System.Runtime]System.Type::op_Inequality([System.Runtime]System.Type,
[System.Runtime]System.Type)
IL_001a: brfalse IL_015a
```
In gshared code, !!T is usually constrained to be a reference, or to have a primitive base type.
Use this fact to eliminate some of the Type::op_Equality/op_Inequality () calls.
Fixes dotnet#54849.
vargaz
force-pushed
the
type-eq-elim
branch
from
September 27, 2021 14:41
20b9c84 to
b532ed5
Compare
vargaz
marked this pull request as ready for review
September 27, 2021 21:58
lambdageek
approved these changes
Sep 28, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.