JIT does not use BT instruction for constant mask #111554
Open
Description
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