Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Created December 5, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohhoy/c832d024b8bfce8fab0ad9eb6eac45a1 to your computer and use it in GitHub Desktop.
Save yohhoy/c832d024b8bfce8fab0ad9eb6eac45a1 to your computer and use it in GitHub Desktop.
// for i in 0..v.len() {sum += v[i];}
// https://play.rust-lang.org/?version=stable&mode=release&edition=2015&gist=a234fd242a39e0e33d1775ba986a7f50
playground::main:
pushq %r14
pushq %rbx
subq $152, %rsp
movq $0, 16(%rsp)
movl $800000000, %edi
movl $8, %esi
callq __rust_alloc@PLT
testq %rax, %rax
je .LBB5_11
movq %rax, %rbx
movl $10, %eax
movaps .LCPI5_0(%rip), %xmm0
.LBB5_2:
movups %xmm0, -80(%rbx,%rax,8)
movups %xmm0, -64(%rbx,%rax,8)
movups %xmm0, -48(%rbx,%rax,8)
movups %xmm0, -32(%rbx,%rax,8)
movups %xmm0, -16(%rbx,%rax,8)
movups %xmm0, (%rbx,%rax,8)
addq $12, %rax
cmpq $100000006, %rax
jne .LBB5_2
movq $1, 799999968(%rbx)
movq $1, 799999976(%rbx)
movq $1, 799999984(%rbx)
movq $1, 799999992(%rbx)
movq %rbx, 128(%rsp)
movdqa .LCPI5_1(%rip), %xmm0
movdqu %xmm0, 136(%rsp)
callq std::time::Instant::now@PLT
movq %rax, 112(%rsp)
movq %rdx, 120(%rsp)
pxor %xmm0, %xmm0
movl $18, %eax
pxor %xmm1, %xmm1
.LBB5_5:
movdqu -144(%rbx,%rax,8), %xmm2
paddq %xmm0, %xmm2
movdqu -128(%rbx,%rax,8), %xmm0
paddq %xmm1, %xmm0
movdqu -112(%rbx,%rax,8), %xmm1
movdqu -96(%rbx,%rax,8), %xmm3
movdqu -80(%rbx,%rax,8), %xmm4
paddq %xmm1, %xmm4
paddq %xmm2, %xmm4
movdqu -64(%rbx,%rax,8), %xmm2
paddq %xmm3, %xmm2
paddq %xmm0, %xmm2
movdqu -48(%rbx,%rax,8), %xmm1
movdqu -32(%rbx,%rax,8), %xmm3
movdqu -16(%rbx,%rax,8), %xmm0
paddq %xmm1, %xmm0
paddq %xmm4, %xmm0
movdqu (%rbx,%rax,8), %xmm1
paddq %xmm3, %xmm1
paddq %xmm2, %xmm1
addq $20, %rax
cmpq $100000018, %rax
jne .LBB5_5
paddq %xmm0, %xmm1
pshufd $78, %xmm1, %xmm0
paddq %xmm1, %xmm0
movq %xmm0, 16(%rsp)
leaq 112(%rsp), %rdi
callq std::time::Instant::elapsed@PLT
movq %rax, 72(%rsp)
movl %edx, 12(%rsp)
leaq 72(%rsp), %rax
movq %rax, 80(%rsp)
movq core::fmt::num::<impl core::fmt::Display for u64>::fmt@GOTPCREL(%rip), %rax
movq %rax, 88(%rsp)
leaq 12(%rsp), %rax
movq %rax, 96(%rsp)
movq core::fmt::num::<impl core::fmt::Display for u32>::fmt@GOTPCREL(%rip), %rax
movq %rax, 104(%rsp)
leaq .L__unnamed_2(%rip), %rax
movq %rax, 24(%rsp)
movq $3, 32(%rsp)
leaq .L__unnamed_3(%rip), %rax
movq %rax, 40(%rsp)
movq $2, 48(%rsp)
leaq 80(%rsp), %r14
movq %r14, 56(%rsp)
movq $2, 64(%rsp)
leaq 24(%rsp), %rdi
callq std::io::stdio::_print@PLT
leaq 16(%rsp), %rax
movq %rax, 80(%rsp)
movq core::fmt::num::<impl core::fmt::Display for usize>::fmt@GOTPCREL(%rip), %rax
movq %rax, 88(%rsp)
leaq .L__unnamed_4(%rip), %rax
movq %rax, 24(%rsp)
movq $2, 32(%rsp)
leaq .L__unnamed_5(%rip), %rax
movq %rax, 40(%rsp)
movq $1, 48(%rsp)
movq %r14, 56(%rsp)
movq $1, 64(%rsp)
leaq 24(%rsp), %rdi
callq std::io::stdio::_print@PLT
movl $800000000, %esi
movl $8, %edx
movq %rbx, %rdi
callq __rust_dealloc@PLT
addq $152, %rsp
popq %rbx
popq %r14
retq
// for i in v {sum += i;}
// https://play.rust-lang.org/?version=stable&mode=release&edition=2015&gist=40dc2e0249c8197f3357beb980aaea2b
playground::main:
pushq %rbx
subq $144, %rsp
movq $0, 8(%rsp)
movl $800000000, %edi
movl $8, %esi
callq __rust_alloc@PLT
testq %rax, %rax
je .LBB5_8
movq %rax, %rbx
movl $10, %eax
movaps .LCPI5_0(%rip), %xmm0
.LBB5_2:
movups %xmm0, -80(%rbx,%rax,8)
movups %xmm0, -64(%rbx,%rax,8)
movups %xmm0, -48(%rbx,%rax,8)
movups %xmm0, -32(%rbx,%rax,8)
movups %xmm0, -16(%rbx,%rax,8)
movups %xmm0, (%rbx,%rax,8)
addq $12, %rax
cmpq $100000006, %rax
jne .LBB5_2
movq $1, 799999968(%rbx)
movq $1, 799999976(%rbx)
movq $1, 799999984(%rbx)
movq $1, 799999992(%rbx)
movq %rbx, 120(%rsp)
movdqa .LCPI5_1(%rip), %xmm0
movdqu %xmm0, 128(%rsp)
callq std::time::Instant::now@PLT
movq %rax, 104(%rsp)
movq %rdx, 112(%rsp)
pxor %xmm0, %xmm0
movl $18, %eax
pxor %xmm1, %xmm1
.LBB5_5:
movdqu -144(%rbx,%rax,8), %xmm2
paddq %xmm0, %xmm2
movdqu -128(%rbx,%rax,8), %xmm0
paddq %xmm1, %xmm0
movdqu -112(%rbx,%rax,8), %xmm1
movdqu -96(%rbx,%rax,8), %xmm3
movdqu -80(%rbx,%rax,8), %xmm4
paddq %xmm1, %xmm4
paddq %xmm2, %xmm4
movdqu -64(%rbx,%rax,8), %xmm2
paddq %xmm3, %xmm2
paddq %xmm0, %xmm2
movdqu -48(%rbx,%rax,8), %xmm1
movdqu -32(%rbx,%rax,8), %xmm3
movdqu -16(%rbx,%rax,8), %xmm0
paddq %xmm1, %xmm0
paddq %xmm4, %xmm0
movdqu (%rbx,%rax,8), %xmm1
paddq %xmm3, %xmm1
paddq %xmm2, %xmm1
addq $20, %rax
cmpq $100000018, %rax
jne .LBB5_5
paddq %xmm0, %xmm1
pshufd $78, %xmm1, %xmm0
paddq %xmm1, %xmm0
movq %xmm0, 8(%rsp)
movl $800000000, %esi
movl $8, %edx
movq %rbx, %rdi
callq __rust_dealloc@PLT
leaq 104(%rsp), %rdi
callq std::time::Instant::elapsed@PLT
movq %rax, 64(%rsp)
movl %edx, 4(%rsp)
leaq 64(%rsp), %rax
movq %rax, 72(%rsp)
movq core::fmt::num::<impl core::fmt::Display for u64>::fmt@GOTPCREL(%rip), %rax
movq %rax, 80(%rsp)
leaq 4(%rsp), %rax
movq %rax, 88(%rsp)
movq core::fmt::num::<impl core::fmt::Display for u32>::fmt@GOTPCREL(%rip), %rax
movq %rax, 96(%rsp)
leaq .L__unnamed_2(%rip), %rax
movq %rax, 16(%rsp)
movq $3, 24(%rsp)
leaq .L__unnamed_3(%rip), %rax
movq %rax, 32(%rsp)
movq $2, 40(%rsp)
leaq 72(%rsp), %rbx
movq %rbx, 48(%rsp)
movq $2, 56(%rsp)
leaq 16(%rsp), %rdi
callq std::io::stdio::_print@PLT
leaq 8(%rsp), %rax
movq %rax, 72(%rsp)
movq core::fmt::num::<impl core::fmt::Display for usize>::fmt@GOTPCREL(%rip), %rax
movq %rax, 80(%rsp)
leaq .L__unnamed_4(%rip), %rax
movq %rax, 16(%rsp)
movq $2, 24(%rsp)
leaq .L__unnamed_5(%rip), %rax
movq %rax, 32(%rsp)
movq $1, 40(%rsp)
movq %rbx, 48(%rsp)
movq $1, 56(%rsp)
leaq 16(%rsp), %rdi
callq std::io::stdio::_print@PLT
addq $144, %rsp
popq %rbx
retq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment