Skip to content

JIT: Suboptimal codegen for string comparison against a const #119115

@rameel

Description

@rameel

sharplab | godbolt

public static int N1(ReadOnlySpan<char> path)
{
    if (path.StartsWith(@"\\?\UNC\", StringComparison.OrdinalIgnoreCase))
        return 8;
    return 0;
}

The relevant part:
crossgen2 trunk-20250826+5a6dcb8c39dffc581e4259738d64352acbd1c439

vptest   xmm0, xmm0
sete     al        ; <--
movzx    rax, al   ; <-- Redundant
test     eax, eax  ; <--
jne      SHORT G_M59455_IG06

Expected:

vptest   xmm0, xmm0
je       SHORT G_M59455_IG06

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions