-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Implement BinaryPrimitives.ReverseEndianness for arm64 using rev #34617
Conversation
Would @TamarChristinaArm, could you advise? Is there also a good location to find this information or cycle approximations in general? |
Was confused by the clang's codegen: https://godbolt.org/z/w_8LUC |
New codegen for static ushort Foo1(ushort a) => BinaryPrimitives.ReverseEndianness(a); ; Assembly listing for method Program:Foo1(ushort):ushort
; Emitting BLENDED_CODE for generic ARM64 CPU - Unix
; optimized code
; fp based frame
; partially interruptible
; Final local variable assignments
;
; V00 arg0 [V00,T00] ( 3, 3 ) ushort -> x0
;# V01 OutArgs [V01 ] ( 1, 1 ) lclBlk ( 0) [sp+0x00] "OutgoingArgSpace"
;
; Lcl frame size = 0
G_M15320_IG01:
A9BF7BFD stp fp, lr, [sp,#-16]!
910003FD mov fp, sp
;; bbWeight=1 PerfScore 1.50
G_M15320_IG02:
53003C00 uxth w0, w0
5AC00400 rev16 w0, w0
53003C00 uxth w0, w0
;; bbWeight=1 PerfScore 1.50
G_M15320_IG03:
A8C17BFD ldp fp, lr, [sp],#16
D65F03C0 ret lr
;; bbWeight=1 PerfScore 2.00
; Total bytes of code 28, prolog size 8, PerfScore 7.80, (MethodHash=a63ec427) for method Program:Foo1(ushort):ushort
; ============================================================
|
Here is what Mono-LLVM-JIT (LLVM 6.0) emits on my Cortex A57 machine: static ushort Foo1(ushort a) => BinaryPrimitives.ReverseEndianness(a); define monocc i16 @"Program:Foo1 (uint16)"(i16 %arg_a) #0 {
BB0:
%rev = call i16 @llvm.bswap.i16(i16 %arg_a)
ret i16 %rev
} 0: 5ac00808 rev w8, w0
4: 53107d00 lsr w0, w8, #16
8: d65f03c0 ret |
The
You can find these in the optimization guides, the one for Cortex-A55 is https://developer.arm.com/docs/epm128372/30/arm-cortex-a55-software-optimization-guide |
I guess it's ready for review then |
CC. @CarolEidt, @echesakovMSFT, @dotnet/jit-contrib |
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.
LGTM
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.
LGTM
Don't know how to restart the "in progress" leg 😕 |
AzDO shows that it has passed: https://dev.azure.com/dnceng/public/_build/results?buildId=605791&view=results |
@BruceForstall can this be merged? |
It looks that we never gonna see runtime (Installer Build and Test Windows_NT_arm Debug) leg completed :) |
@Gnbrkm41 noticed it's not currently optimized to
rev
.Old codegen:
New codegen:
int16 is not implemented yet, perhaps should be implemented in C# instead? To call the int-overload and apply a shift.
Tests already exist: https://github.com/dotnet/runtime/blob/master/src/coreclr/tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness.cs