Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop generic type constraints from Unsafe.BitCast #100842

Merged
merged 7 commits into from
Apr 15, 2024

Conversation

MihaZupan
Copy link
Member

Fixes #99205
Fixes #99006

MihuBot/runtime-utils#354

Most diffs appear to be more inlining / removing unreachable branches. For example seeing that these IndexOf* calls are passing in 0 and therefore deleting the checks and unreachable calls to PackedSpanHelpers

int possibleUtf8Pos = input.AsSpan().IndexOfAnyExceptInRange((char)0, (char)127);
if (possibleUtf8Pos >= 0 &&
!input.AsSpan(possibleUtf8Pos).ContainsAnyExceptInRange((char)0, (char)255))

Part of the diff
 G_M22867_IG04:
-       xor      edx, edx
-       mov      dword ptr [rbp-0x2C], edx
-       mov      dword ptr [rbp-0x30], 127
-       movzx    rsi, word  ptr [rbp-0x2C]
-       movzx    rdx, word  ptr [rbp-0x30]
-       lea      r8d, [rsi-0x01]
-       cmp      r8d, 254
-       jae      SHORT G_M22867_IG05
-       lea      r8d, [rdx-0x01]
-       cmp      r8d, 254
-       jae      SHORT G_M22867_IG05
-       cmp      edx, esi
-       jl       SHORT G_M22867_IG05
-       sub      edx, esi
-       movsx    rdx, dx
-       movsx    rsi, si
-       mov      rdi, rax
-       mov      rax, 0xD1FFAB1E      ; code for System.PackedSpanHelpers:IndexOfAnyInRange[System.SpanHelpers+Negate`1[short]](byref,short,short,int):int
-       call     [rax]System.PackedSpanHelpers:IndexOfAnyInRange[System.SpanHelpers+Negate`1[short]](byref,short,short,int):int
-       jmp      SHORT G_M22867_IG06
-						;; size=77 bbWeight=1 PerfScore 15.25
-G_M22867_IG05:
-       mov      rdi, rax
+       mov      rdi, rcx
+       mov      ecx, esi
+       xor      esi, esi
+       mov      edx, 127
        mov      rax, 0xD1FFAB1E      ; code for System.SpanHelpers:NonPackedIndexOfAnyInRangeUnsignedNumber[ushort,System.SpanHelpers+Negate`1[ushort]](byref,ushort,ushort,int):int
        call     [rax]System.SpanHelpers:NonPackedIndexOfAnyInRangeUnsignedNumber[ushort,System.SpanHelpers+Negate`1[ushort]](byref,ushort,ushort,int):int

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tannergooding tannergooding merged commit 617f81f into dotnet:main Apr 15, 2024
154 of 156 checks passed
@jakobbotsch
Copy link
Member

jakobbotsch commented Apr 15, 2024

FYI @dotnet/jit-contrib (JIT-EE GUID changed)

@tannergooding
Copy link
Member

Sorry, I had thought jit-contrib had already been tagged above but now I see the area tag ended up being CompilerServices instead.

@LoopedBard3
Copy link
Member

Another potentially related regression issue @MihaZupan
Windows x64: dotnet/perf-autofiling-issues#33044 (Only the IndexOfAny test)

matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
* Drop generic type constraints from Unsafe.BitCast

* Add isNullableType to JIT interface

* superpmi

* Comment formatting

* Check IsGenericParameter instead of Canon

* Replace IsGenericParameter check with assert

* Just kidding, remove it completely :D
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants