Skip to content

[RyuJIT][arm64] Optimize "x<0" and "x>=0" #43440

Closed

Description

@EgorBo

There are two cases:

Case1:

static bool Case1(int x) => x < 0; // probably also `x >= 0`

current codegen:

    cmp     w0, #0
    cset    x0, lt

expected codegen:

    lsr     x0, w0, #31

x86-related PR: #35627

Case2 (jump condition):

static void Case2(int a)
{
    if (a < 0) // and "a >= 0"
        Foo();
}

current codegen:

    cmp     w0, #0
    bge     G_M29168_IG04

expected codegen:

    tbnz    w0, #31, G_M29168_IG04

NOTE: for the second case we already have an optimization for x==0 -> tb(n)z so should be easy to extend.

/cc @kunalspathak @echesakovMSFT

category:cq
theme:codegen
skill-level:intermediate
cost:medium
impact:medium

Activity

  1. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    untriagedNew issue has not been triaged by the area owner
    on Oct 15, 2020
  2. removed
    untriagedNew issue has not been triaged by the area owner
    on Oct 16, 2020
  3. added this to the Future milestone on Oct 16, 2020
  4. echesakov commented on Oct 16, 2020

    @echesakov
    Contributor

    Thanks @EgorBo for opening this. I will add the optimizations to .NET 6 Arm64 "Epic" issue I am working right now as a potential work in .NET 6.

  5. added and removed
    JitUntriagedCLR JIT issues needing additional triage
    on Nov 7, 2020
  6. self-assigned this
    on Oct 31, 2022
  7. modified the milestones: Future, 8.0.0 on Jan 17, 2023
  8. ghost locked as resolved and limited conversation to collaborators on Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-arm64area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions