Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created April 19, 2021 18:00
Show Gist options
  • Save alexcrichton/09153c3c1f95dd738e19204f43781fdb to your computer and use it in GitHub Desktop.
Save alexcrichton/09153c3c1f95dd738e19204f43781fdb to your computer and use it in GitHub Desktop.
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 7
.section __TEXT,__literal4,4byte_literals
.p2align 2
LCPI0_0:
.long 0x4effffff
LCPI0_1:
.long 0xcf000000
.section __TEXT,__text,regular,pure_instructions
.globl _foo
.p2align 4, 0x90
_foo:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
ucomiss LCPI0_0(%rip), %xmm0
movaps %xmm0, %xmm1
maxss LCPI0_1(%rip), %xmm1
cvttss2si %xmm1, %eax
movl $2147483647, %ecx
cmovbel %eax, %ecx
xorl %eax, %eax
ucomiss %xmm0, %xmm0
cmovnpl %ecx, %eax
popq %rbp
retq
.cfi_endproc
.subsections_via_symbols
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 7
.section __TEXT,__literal4,4byte_literals
.p2align 2
LCPI0_0:
.long 0x4effffff
.section __TEXT,__text,regular,pure_instructions
.globl _foo
.p2align 4, 0x90
_foo:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
cvttss2si %xmm0, %eax
ucomiss LCPI0_0(%rip), %xmm0
movl $2147483647, %ecx
cmovbel %eax, %ecx
xorl %eax, %eax
ucomiss %xmm0, %xmm0
cmovnpl %ecx, %eax
popq %rbp
retq
.cfi_endproc
.subsections_via_symbols
--- a-before.s 2021-04-19 11:00:07.000000000 -0700
+++ b-after.s 2021-04-19 11:00:06.000000000 -0700
@@ -4,8 +4,6 @@
.p2align 2
LCPI0_0:
.long 0x4effffff
-LCPI0_1:
- .long 0xcf000000
.section __TEXT,__text,regular,pure_instructions
.globl _foo
.p2align 4, 0x90
@@ -16,10 +14,8 @@
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
+ cvttss2si %xmm0, %eax
ucomiss LCPI0_0(%rip), %xmm0
- movaps %xmm0, %xmm1
- maxss LCPI0_1(%rip), %xmm1
- cvttss2si %xmm1, %eax
movl $2147483647, %ecx
cmovbel %eax, %ecx
xorl %eax, %eax
#[no_mangle]
pub extern "C" fn foo(a: f32) -> i32 {
a as i32
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment