What is most efficient way to saturate int64 value to int32 with ARMv4 instruction set?
Asked
Active
Viewed 251 times
1 Answers
1
This is close, but the negative clipping to 0x80000000 isn't working. I'll have to think about it a bit longer.
; saturate signed 64-bit int in rhi:rlo to a signed 32-bit int in rlo
CMP rhi, rlo, ASR #31
; if EQ then the high 33-bit are all the same and the answer is rlo
; else the answer is (rhi:31 is set) ? 0x80000000 : 0x7fffffff
MOVNE rlo, rhi, ASR #31
MVNNE rtmp, rlo ; 'rtmp' can be 'rhi'
EORNE rlo, rlo, rtmp, LSR #1

scott
- 728
- 4
- 8