Open
Description
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