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

JIT: Bound check elimination regression #109365

Closed
hez2010 opened this issue Oct 30, 2024 · 2 comments · Fixed by #109466
Closed

JIT: Bound check elimination regression #109365

hez2010 opened this issue Oct 30, 2024 · 2 comments · Fixed by #109466
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI in-pr There is an active PR which will close this issue when it is merged tenet-performance Performance related issue
Milestone

Comments

@hez2010
Copy link
Contributor

hez2010 commented Oct 30, 2024

Description

Repro:

using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Threading;

class C
{
    private readonly static int[] _perm = [1,2,3,4];
    [MethodImpl(MethodImplOptions.NoInlining)]
    public int Hash(int value)
    {
        return _perm[value & (_perm.Length - 1)];
    }

    static void Main()
    {
        var c = new C();
        for (var i = 0; i < 1000; i++) // triggers tier-1
        {
            c.Hash(i);
            Thread.Sleep(1);
        }
    }
}

On .NET 9:

G_M000_IG01:                ;; offset=0x0000

G_M000_IG02:                ;; offset=0x0000
       mov      rax, 0x2170C000150
       mov      rax, gword ptr [rax]
       and      edx, 3
       mov      ecx, edx
       mov      eax, dword ptr [rax+4*rcx+0x10]

G_M000_IG03:                ;; offset=0x0016
       ret

On main:

G_M45462_IG01:  ;; offset=0x0000
       push     rax
						;; size=1 bbWeight=1 PerfScore 1.00
G_M45462_IG02:  ;; offset=0x0001
       mov      rax, 0x727ECC000180      ; const ptr
       mov      rax, gword ptr [rax]
       and      esi, 3
       cmp      esi, 4
       jae      SHORT G_M45462_IG04
       mov      ecx, esi
       mov      eax, dword ptr [rax+4*rcx+0x10]
						;; size=27 bbWeight=1 PerfScore 6.00
G_M45462_IG03:  ;; offset=0x001C
       add      rsp, 8
       ret      
						;; size=5 bbWeight=1 PerfScore 1.25
G_M45462_IG04:  ;; offset=0x0021
       call     CORINFO_HELP_RNGCHKFAIL
       int3     

Configuration

.NET 9, .NET 10 nightly

Regression?

Yes

@hez2010 hez2010 added the tenet-performance Performance related issue label Oct 30, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 30, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 30, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jakobbotsch
Copy link
Member

jakobbotsch commented Oct 30, 2024

Bisected to 82256bf...489a151, i.e. #108606, cc @MichalPetryka @EgorBo

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Nov 1, 2024
@EgorBo EgorBo self-assigned this Nov 2, 2024
@EgorBo EgorBo added this to the 10.0.0 milestone Nov 2, 2024
@EgorBo EgorBo removed the untriaged New issue has not been triaged by the area owner label Nov 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI in-pr There is an active PR which will close this issue when it is merged tenet-performance Performance related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants