Skip to content

Codegen for some bitflag checks could be optimized #13743

Description

@GrabYourPitchforks

More info: dotnet/coreclr#27603 (comment)

Sample code:

public static bool HasHighBitSet(uint value) {
    return (value & 0x8000_0000) != 0;
}

Actual codegen:

    L0000: test ecx, 0x80000000
    L0006: setnz al
    L0009: movzx eax, al
    L000c: ret

Replacing the first two instructions with test ecx, ecx and setl al would save 4 bytes of codegen. It's a minor savings but might help if this pattern occurs within a hot loop.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    JitUntriagedCLR JIT issues needing additional triagearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIoptimization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions