使用ARMv4指令集将int64值饱和到int32的最有效方法是什么?
答案 0 :(得分:1)
这很接近,但对0x80000000的负裁剪不起作用。我不得不考虑一下。
; 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