Skip to content

Redundant TEST instruction after ADD #117866

@rameel

Description

@rameel

godbolt | sharplab

Minimal repro:

public static void X(int value)
{
    while (true)
    {
        value -= 16;
        if (value <= 0) 
            break;
    }
}

coreclr trunk-20250720+5630010c13adad214fc369a365d0225d4b207ec6:

G_M42956_IG03:  ;; offset=0x0004
       add      edi, -16
       test     edi, edi ; <-- flags already set by ADD
       jg       SHORT G_M42956_IG03

Expected:

G_M42956_IG03:  ;; offset=0x0004
       add      edi, -16
       jg       SHORT G_M42956_IG03

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions