Skip to content

JIT does not use BT instruction for constant maskย #111554

Closed
@rameel

Description

@rameel
public static bool CheckLetterOrDigit(int uc)
{
    return (LetterOrDigitCategories & (1 << uc)) != 0;
}
L0000: mov eax, 1
L0005: shlx eax, eax, ecx
L000a: test eax, 0x11f
L000f: setne al
L0012: movzx eax, al
L0015: ret
public static bool CheckLetterOrDigit(int mask, int uc)
{
    return (mask & (1 << uc)) != 0;
}
L0000: bt ecx, edx
L0003: setb al
L0006: movzx eax, al
L0009: ret

A more complete example sharplab where

L0032: mov eax, 1
L0037: shlx eax, eax, edx
L003c: test eax, 0x11f
L0041: je short L0056

could be optimized to

L0032: mov eax, 0x11f
L0037: bt eax, edx
L003a: jae short L0056

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 contributorsin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions