JIT: Suboptimal codegen for string comparison against a const

Open
#119,115 1 comment 0 reactions 1 assignee View on GitHub

@EgorBo is already working on this.

Since Aug 27, 2025.

Assessment

This issue has not been assessed yet.

Description

area-CodeGen-coreclr

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
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.