Repro, courtesy sharplab:
public static bool CompareAgainstConstInt(int a) {
return (a & 0x40) == 0;
}
public static bool CompareAgainstConstUInt(int a) {
return (a & 0x40u) == 0;
}
; C.CompareAgainstConstInt(Int32)
L0000: test cl, 0x40
L0003: setz al
L0006: movzx eax, al
L0009: ret
; C.CompareAgainstConstUInt(Int32)
L0000: movsxd rax, ecx ; <-- this is unnecessary
L0003: test al, 0x40
L0005: setz al
L0008: movzx eax, al
L000b: ret
category:cq
theme:optimization
skill-level:intermediate
cost:medium