Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #74873
EgorBo opened this issue Mar 22, 2021 · 2 comments
Closed
Tracked by #74873

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

EgorBo opened this issue Mar 22, 2021 · 2 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI tenet-performance Performance related issue
Milestone

Comments

@EgorBo
Copy link
Member

EgorBo commented Mar 22, 2021

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

@EgorBo EgorBo added the tenet-performance Performance related issue label Mar 22, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Mar 22, 2021
@EgorBo EgorBo added this to the 6.0.0 milestone Mar 22, 2021
@EgorBo EgorBo removed the untriaged New issue has not been triaged by the area owner label Mar 22, 2021
@EgorBo EgorBo self-assigned this Mar 22, 2021
@EgorBo EgorBo changed the title Incorrect weights produced by expand-casts optimizations [JIT][PGO] Incorrect weights produced by expand-casts optimizations Mar 22, 2021
@EgorBo
Copy link
Member Author

EgorBo commented Mar 22, 2021

Even weirder weights here:

static bool Foo(object o) => o is string;
; Method Program:Foo(System.Object):bool
G_M5401_IG01:              ;; offset=0000H
						;; bbWeight=1    PerfScore 0.00

G_M5401_IG02:              ;; offset=0000H
       4885C9               test     rcx, rcx
       7411                 je       SHORT G_M5401_IG05
						;; bbWeight=1    PerfScore 1.25

G_M5401_IG03:              ;; offset=0005H
       48B8B873CEE9F97F0000 mov      rax, 0x7FF9E9CE73B8
       483901               cmp      qword ptr [rcx], rax
       7402                 je       SHORT G_M5401_IG05
						;; bbWeight=0.25 PerfScore 0.81

G_M5401_IG04:              ;; offset=0014H
       33C9                 xor      rcx, rcx
						;; bbWeight=0.13 PerfScore 0.03

G_M5401_IG05:              ;; offset=0016H
       4885C9               test     rcx, rcx
       0F95C0               setne    al
       0FB6C0               movzx    rax, al
						;; bbWeight=1    PerfScore 1.50

G_M5401_IG06:              ;; offset=001FH
       C3                   ret      
						;; bbWeight=1    PerfScore 1.00
; Total bytes of code: 32

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 23, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Apr 6, 2021
@EgorBo EgorBo modified the milestones: 6.0.0, Future May 24, 2021
@EgorBo EgorBo modified the milestones: Future, 9.0.0 May 5, 2024
@EgorBo
Copy link
Member Author

EgorBo commented May 5, 2024

Fixed by the "late cast expansion" work in 9.0

@EgorBo EgorBo closed this as completed May 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI tenet-performance Performance related issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant