Created
November 10, 2017 04:55
-
-
Save sunfishcode/859d97e2758e02015728f70f7cde15c3 to your computer and use it in GitHub Desktop.
Efficient x86 saturating float->int conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.globl bar | |
.p2align 4, 0x90 | |
.type bar,@function | |
bar: | |
.cfi_startproc | |
cvttss2si %xmm0, %eax | |
cmpl $1, %eax | |
jo 0f | |
retq | |
0: | |
xorps %xmm1, %xmm1 | |
ucomiss %xmm0, %xmm1 | |
jnp 0f | |
xorl %eax, %eax | |
0: | |
sbbl $0, %eax | |
retq | |
.cfi_endproc | |
.size bar, .-bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment