Skip to content

[JIT][PGO] Incorrect weights produced by expand-casts optimizations #50030

@EgorBo

Description

@EgorBo
static string Foo(object o) => (string)o;

Currently produces:

; Method Program:Foo(System.Object):System.String
G_M28009_IG01:              ;; offset=0000H
       4883EC28             sub      rsp, 40
						;; bbWeight=1    PerfScore 0.25

G_M28009_IG02:              ;; offset=0004H
       48894C2430           mov      gword ptr [rsp+30H], rcx
       488BC1               mov      rax, rcx
       4885C0               test     rax, rax
       740F                 je       SHORT G_M28009_IG04
						;; bbWeight=1    PerfScore 2.50

G_M28009_IG03:              ;; offset=0011H
       48BAB873D0E9F97F0000 mov      rdx, 0x7FF9E9D073B8
       483910               cmp      qword ptr [rax], rdx
       7505                 jne      SHORT G_M28009_IG05
						;; bbWeight=0.25 PerfScore 0.81

G_M28009_IG04:              ;; offset=0020H
       4883C428             add      rsp, 40
       C3                   ret      
						;; bbWeight=1    PerfScore 1.25

G_M28009_IG05:              ;; offset=0025H
       488BCA               mov      rcx, rdx
       488B542430           mov      rdx, gword ptr [rsp+30H]
       E83E7BACFF           call     CORINFO_HELP_CHKCASTCLASS_SPECIAL
       CC                   int3     
						;; bbWeight=0    PerfScore 0.00
; Total bytes of code: 51

Note that 0.25 weight which looks incorrect.

Same for some other cast patterns.

category:correctness
theme:profile-feedback
skill-level:intermediate
cost:small
impact:small

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions