-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue
Milestone
Description
Description
It appears that array variance checks against e.g. List<T> are not optimized away for patterns like (obj)list is int[].
Configuration
.NET 8.0.100
Regression?
No
Analysis
Given below pattern
static bool Foo(List<int> l)
{
return (object)l is int[];
}The produced asm is
G_M39343_IG01: ;; offset=0x0000
push rax
G_M39343_IG02: ;; offset=0x0001
mov rsi, rdi
mov rdi, 0x7FDDF17D91D0 ; int[]
call [CORINFO_HELP_ISINSTANCEOFARRAY]
test rax, rax
setne al
movzx rax, al
G_M39343_IG03: ;; offset=0x001D
add rsp, 8
ret instead of
xor rax, rax
retShould this pattern get optimized, this will allow to update e.g. Enumerable.SequenceEquals in such a way that type tests are optimized away and it directly forwards to CollectionsMarshal.AsSpan(list).SequenceEquals(...).
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue