Uh oh!
There was an error while loading. Please reload this page.
Implement BinaryPrimitives.ReverseEndianness for arm64 using rev - #34617
Conversation
tannergooding
commented
Apr 7, 2020
Would @TamarChristinaArm, could you advise? Is there also a good location to find this information or cycle approximations in general? |
EgorBo
commented
Apr 7, 2020
Was confused by the clang's codegen: https://godbolt.org/z/w_8LUC |
EgorBo
commented
Apr 7, 2020
New codegen for staticushortFoo1(ushorta)=>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 = 0G_M15320_IG01: A9BF7BFD stp fp, lr,[sp,#-16]! 910003FD mov fp,sp ;; bbWeight=1 PerfScore 1.50G_M15320_IG02: 53003C00 uxth w0, w0 5AC00400 rev16 w0, w0 53003C00 uxth w0, w0 ;; bbWeight=1 PerfScore 1.50G_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; ============================================================ |
EgorBo
commented
Apr 7, 2020
Here is what Mono-LLVM-JIT (LLVM 6.0) emits on my Cortex A57 machine: staticushortFoo1(ushorta)=>BinaryPrimitives.ReverseEndianness(a);define monocc i16 @"Program:Foo1 (uint16)"(i16%arg_a) #0 {
BB0:
%rev = calli16@llvm.bswap.i16(i16%arg_a)
reti16%rev
}0: 5ac00808 rev w8, w04: 53107d00 lsr w0, w8, #168: d65f03c0 ret |
TamarChristinaArm
commented
Apr 7, 2020
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 |
EgorBo
commented
Apr 13, 2020
I guess it's ready for review then |
tannergooding
commented
Apr 13, 2020
CC. @CarolEidt, @echesakovMSFT, @dotnet/jit-contrib |
Uh oh!
There was an error while loading. Please reload this page.
EgorBo
commented
Apr 18, 2020
Don't know how to restart the "in progress" leg 😕 |
sandreenko
commented
Apr 19, 2020
AzDO shows that it has passed: https://dev.azure.com/dnceng/public/_build/results?buildId=605791&view=results |
EgorBo
commented
Apr 24, 2020
@BruceForstall can this be merged? |
echesakov
commented
Apr 24, 2020
It looks that we never gonna see runtime (Installer Build and Test Windows_NT_arm Debug) leg completed :) |
@Gnbrkm41noticed 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