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: Tune CSE/Constant propagation to fix this SIMD example #70657

Closed
EgorBo opened this issue Jun 13, 2022 · 2 comments
Closed

JIT: Tune CSE/Constant propagation to fix this SIMD example #70657

EgorBo opened this issue Jun 13, 2022 · 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 Jun 13, 2022

Found during review of #70654

Vector128<byte> Test(Vector128<byte> a, Vector128<byte> b) 
    => Vector128.GreaterThan(a, b);

Current codegen:

G_M23213_IG01:
       vzeroupper 
G_M23213_IG02:
       vmovupd  xmm0, xmmword ptr [r8]
       vpsubb   xmm0, xmm0, xmmword ptr [reloc @RWD00]
       vmovupd  xmm1, xmmword ptr [r9]
       vpsubb   xmm1, xmm1, xmmword ptr [reloc @RWD00]
       vpcmpgtb xmm0, xmm0, xmm1
       vmovupd  xmmword ptr [rdx], xmm0
       mov      rax, rdx
G_M23213_IG03:
       ret      
RWD00  	dq	8080808080808080h, 8080808080808080h
; Total bytes of code: 41

Here, before vpcmpgtb we subtract a constant vector from both xmm0 and xmm1 - CSE should be able to handle them and give constant propagation a hint that it should not propagate them back.

category:cq
theme:assertion-prop
skill-level:intermediate
cost:small
impact:medium

@EgorBo EgorBo added the tenet-performance Performance related issue label Jun 13, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 13, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 13, 2022
@EgorBo EgorBo added this to the 8.0.0 milestone Jun 13, 2022
@ghost
Copy link

ghost commented Jun 13, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Found during review of #70654

Vector128<byte> Test(Vector128<byte> a, Vector128<byte> b) 
    => Vector128.GreaterThan(a, b);

Current codegen:

G_M23213_IG01:
       vzeroupper 
G_M23213_IG02:
       vmovupd  xmm0, xmmword ptr [r8]
       vpsubb   xmm0, xmm0, xmmword ptr [reloc @RWD00]
       vmovupd  xmm1, xmmword ptr [r9]
       vpsubb   xmm1, xmm1, xmmword ptr [reloc @RWD00]
       vpcmpgtb xmm0, xmm0, xmm1
       vmovupd  xmmword ptr [rdx], xmm0
       mov      rax, rdx
G_M23213_IG03:
       ret      
RWD00  	dq	8080808080808080h, 8080808080808080h
; Total bytes of code: 41

Here, before vpcmpgtb we subtract a constant vector from both xmm0 and xmm1 - CSE should be able to handle them and give constant propagation a hint that it should not propagate them back.

Author: EgorBo
Assignees: -
Labels:

tenet-performance, area-CodeGen-coreclr, untriaged

Milestone: -

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 13, 2022
@jakobbotsch
Copy link
Member

Current codegen is:

; Method Program:Test(System.Runtime.Intrinsics.Vector128`1[ubyte],System.Runtime.Intrinsics.Vector128`1[ubyte]):System.Runtime.Intrinsics.Vector128`1[ubyte]:this
G_M40440_IG01:
       vzeroupper 
						;; size=3 bbWeight=1    PerfScore 1.00

G_M40440_IG02:
       vmovupd  xmm0, xmmword ptr [r8]
       vmovupd  xmm1, xmmword ptr [reloc @RWD00]
       vpsubb   xmm0, xmm0, xmm1
       vmovupd  xmm2, xmmword ptr [r9]
       vpsubb   xmm1, xmm2, xmm1
       vpcmpgtb xmm0, xmm0, xmm1
       vmovupd  xmmword ptr [rdx], xmm0
       mov      rax, rdx
						;; size=37 bbWeight=1    PerfScore 14.42

G_M40440_IG03:
       ret      

I assume this was fixed by one of your changes @EgorBo so this can be closed?

@EgorBo EgorBo closed this as completed Apr 24, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 24, 2023
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
None yet
Development

No branches or pull requests

2 participants