Skip to content

StringComparer.OrdinalIgnoreCase.Equals is not unrolled for literals #86999

@EgorBo

Description

@EgorBo
bool Foo1(string s) => s.Equals("Test123", StringComparison.OrdinalIgnoreCase);
bool Foo2(string s) => StringComparer.OrdinalIgnoreCase.Equals(s, "Test123");

Codegen:

; Method Pr:Foo1(System.String):bool:this
       cmp      dword ptr [rdx+08H], 7
       jne      SHORT G_M26946_IG04
       mov      rax, 0x20002000200020
       or       rax, qword ptr [rdx+0CH]
       mov      rcx, 0x74007300650074
       xor      rax, rcx
       mov      rdx, qword ptr [rdx+12H]
       or       rdx, 32
       mov      rcx, 0x33003200310074
       xor      rdx, rcx
       or       rax, rdx
       sete     al
       movzx    rax, al
       jmp      SHORT G_M26946_IG05
G_M26946_IG04:
       xor      eax, eax
G_M26946_IG05:
       ret      
; Total bytes of code: 68


; Method Pr:Foo2(System.String):bool:this
       mov      rcx, 0x11097C00308      ; const ptr
       mov      rcx, gword ptr [rcx]
       mov      r8, 0x11080309270      ; 'Test123'
       tail.jmp [System.OrdinalIgnoreCaseComparer:Equals(System.String,System.String):bool:this]
; Total bytes of code: 29

while Foo2 should emit the same optimized/unrolled codegen as Foo1. Should be a simple change.

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

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions