You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
This diff improves performance for lowering `cvttsd2siq` for Arm64. The code was found in hot code blocks in production.
Old code gen:
```
mrs x0, fpsr
and x0, x0, #0xfffffffffffffffe
msr fpsr, x0
movz x0, #0x8000000000000000
fcvtzs x1, d0
mrs x2, fpsr
tst x2, #0x1
csel x1, x0, x1, ne
movz x0, #0x8000000000000000
cmp x1, x0
b.eq slowpath # if equal, branch to slow path
```
New code gen:
```
ubfx x12, x26, #52, #11 # extract the exponent
cmp x12, #0x43e # compare against 0x43e, which is 63 if unbiased by subtracting 1023
fmov d24, x26 # mov the value to a NEON register
fcvtzs x4, d24 # convert to integer in rounding to zero mode
movz x9, #0x8000000000000000 # INT64_MIN
csel x4, x9, x4, hs # if dbl is positive, dbl >= 2^63 or is infinity or NaN, impossible to
# convert; if dbl is negative, dbl <= INT64_MIN or is infinity or NaN,
# impossible to convert except dbl == INT64_MIN. In all cases, set the
# the value to INT64_MIN and jump to slow path.
cmp x4, x9
b.eq slowpath # if equal, branch to slow path
```
The biggest difference is to not read and write fpsr (floating-point status register), which is slow on Arm64 CPUs.
Reviewed By: ottoni
Differential Revision: D92241953
fbshipit-source-id: 8448b689d48fc7406fafc85f79924cf3d03c8ea1
0 commit comments