-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Optimize scalar conversions with AVX512 #84384
Optimize scalar conversions with AVX512 #84384
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue DetailsDraft PR for testing purposes. No need for review at this time. This PR optimize the following cases:
public static UInt64 FloatToULong(float val)
{
return (UInt64)val;
} Assembly before optimization G_M22196_IG01: ;; offset=0000H
4883EC28 sub rsp, 40
C5F877 vzeroupper
;; size=7 bbWeight=1 PerfScore 1.25
G_M22196_IG02: ;; offset=0007H
62F17E085AC0 vcvtss2sd xmm0, xmm0
E87E57815E call CORINFO_HELP_DBL2ULNG
90 nop
;; size=12 bbWeight=1 PerfScore 5.25
G_M22196_IG03: ;; offset=0013H
4883C428 add rsp, 40
C3 ret
;; size=5 bbWeight=1 PerfScore 1.25 Assembly afteroptimization G_M22196_IG01: ;; offset=0000H
C5F877 vzeroupper
;; size=3 bbWeight=1 PerfScore 1.00
G_M22196_IG02: ;; offset=0003H
62F1FE0878C0 vcvttss2usi rax, xmm0
;; size=6 bbWeight=1 PerfScore 6.00
G_M22196_IG03: ;; offset=0009H
C3 ret
public static UInt64 DoubleToULong(double val)
{
return (UInt64)val;
} Assembly before optimization G_M30068_IG01: ;; offset=0000H
4883EC28 sub rsp, 40
C5F877 vzeroupper
;; size=7 bbWeight=1 PerfScore 1.25
G_M30068_IG02: ;; offset=0007H
E874577F5E call CORINFO_HELP_DBL2ULNG
90 nop
;; size=6 bbWeight=1 PerfScore 1.25
G_M30068_IG03: ;; offset=000DH
4883C428 add rsp, 40
C3 ret Assembly afteroptimization G_M30068_IG01: ;; offset=0000H
C5F877 vzeroupper
;; size=3 bbWeight=1 PerfScore 1.00
G_M30068_IG02: ;; offset=0003H
62F1FF0878C0 vcvttsd2usi rax, xmm0
;; size=6 bbWeight=1 PerfScore 5.00
G_M30068_IG03: ;; offset=0009H
C3 ret
public static double UIntToDouble(UInt64 val)
{
return (double)val;
} Assembly before optimization G_M33997_IG01: ;; offset=0000H
C5F877 vzeroupper
;; size=3 bbWeight=1 PerfScore 1.00
G_M33997_IG02: ;; offset=0003H
62F17C0857C0 vxorps xmm0, xmm0
62F1FF082AC1 vcvtsi2sd xmm0, rcx
4885C9 test rcx, rcx
7D0A jge SHORT G_M33997_IG03
62F1FF08580502000000 vaddsd xmm0, qword ptr [reloc @RWD00]
;; size=27 bbWeight=1 PerfScore 12.58
G_M33997_IG03: ;; offset=001EH
C3 ret Assembly afteroptimization G_M33997_IG01: ;; offset=0000H
C5F877 vzeroupper
;; size=3 bbWeight=1 PerfScore 1.00
G_M33997_IG02: ;; offset=0003H
62F1FF087BC1 vcvtusi2sd xmm0, rcx
;; size=6 bbWeight=1 PerfScore 4.00
G_M33997_IG03: ;; offset=0009H
C3 ret
|
I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
|
src/tests/JIT/Directed/Convert/out_of_range_fp_to_int_conversions.cpp
Outdated
Show resolved
Hide resolved
src/tests/JIT/Directed/Convert/out_of_range_fp_to_int_conversions.cpp
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/UIntPtrTests.GenericMath.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/UIntPtrTests.GenericMath.cs
Outdated
Show resolved
Hide resolved
a2c8d52
to
bb4a91e
Compare
We are narrowing down the scope of the PR to ulong -> float conversions. The changes will b e updated soon. |
@@ -18,8 +18,46 @@ FORCEINLINE int64_t FastDbl2Lng(double val) | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file and in jithelpers.cpp should be rolled back too.
@tannergooding @jkotas does this look good for merge? I have rolled back the changes for float/double -> I long and optimized ulong -> float/double cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. I have commented on a few nits.
Somebody on @dotnet/jit-contrib should do final review and merge.
@jkotas I think we are good to go here. Would you please help with the approval and merge. |
@kunalspathak Could you please do final review and merge? |
@kunalspathak can you help to merge this changes? They have been approved and we are trying to get them in before the next release. |
SPMI failures are the general CI was passing before the minor formatting cleanup requested |
This PR optimize the following cases:
Assembly before optimization
Assembly after optimization
Assembly before optimization
Assembly after optimization