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

RyuJIT doesn't eliminate a jump to the next instruction #4326

Closed
mikedn opened this issue Jun 20, 2015 · 3 comments · Fixed by #69041
Closed

RyuJIT doesn't eliminate a jump to the next instruction #4326

mikedn opened this issue Jun 20, 2015 · 3 comments · Fixed by #69041
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions optimization tenet-performance Performance related issue
Milestone

Comments

@mikedn
Copy link
Contributor

mikedn commented Jun 20, 2015

C# code:

using System;

class Program {
    static int Main(string[] args) {
        return Math.Max(args.Length, 42);
    }
}

Generated code:

G_M17764_IG01:

G_M17764_IG02:
       8B4108               mov      eax, dword ptr [rcx+8]
       83F82A               cmp      eax, 42
       7D07                 jge      SHORT G_M17764_IG03
       B82A000000           mov      eax, 42
       EB00                 jmp      SHORT G_M17764_IG03  ;huh???

G_M17764_IG03:
       C3                   ret

category:cq
theme:basic-cq
skill-level:intermediate
cost:medium

@mikedn mikedn changed the title RyuJIT doesn't eliminate empty block RyuJIT doesn't eliminate a jump to the next instruction Jun 20, 2015
@BruceForstall
Copy link
Member

We thought we were going to need to generate code between the jmp and the ret, but it turned out to just be "mov eax,eax", so we didn't generate it, but it was too late to get rid of the jmp.

@mikedn
Copy link
Contributor Author

mikedn commented Oct 16, 2016

With if-conversion the following code is generated:

G_M45812_IG01:

G_M45812_IG02:
       8B4108               mov      eax, dword ptr [rcx+8]
       83F82A               cmp      eax, 42
       BA2A000000           mov      edx, 42
       0F4CC2               cmovl    eax, edx

G_M45812_IG03:
       C3                   ret

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@msftgits msftgits added this to the Future milestone Jan 30, 2020
@BruceForstall BruceForstall added the JitUntriaged CLR JIT issues needing additional triage label Oct 28, 2020
@BruceForstall
Copy link
Member

This still occurs.

LSRA annotates a block that only contains:

         IL_OFFSET void   IL offset: 0x0 REG NA
t10 =    LCL_VAR   int    V03 tmp2         u:1 rax (last use) REG rax $c0
      /--*  t10    int
      *  STORE_LCL_VAR int    V02 tmp1         d:2 rax REG rax

Perhaps it could delete the code? Not really the RA's job, though.

Maybe this is best handled by a peephole optimization.

@BruceForstall BruceForstall removed the JitUntriaged CLR JIT issues needing additional triage label Dec 1, 2020
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 16, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Apr 25, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label May 9, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 7, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 8, 2022
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 enhancement Product code improvement that does NOT require public API changes/additions optimization tenet-performance Performance related issue
Projects
None yet
3 participants