Skip to content

Instantly share code, notes, and snippets.

@igorw
Created January 9, 2015 20:58
Show Gist options
  • Save igorw/3a24886f15f84e44916f to your computer and use it in GitHub Desktop.
Save igorw/3a24886f15f84e44916f to your computer and use it in GitHub Desktop.
--- divmod2.s 2015-01-09 21:58:10.000000000 +0100
+++ divmod.s 2015-01-09 21:56:08.000000000 +0100
@@ -12,20 +12,27 @@
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
- leaq _divmod.n(%rip), %rax
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
- movl -4(%rbp), %esi
- movq %rax, -16(%rbp) ## 8-byte Spill
- movl %esi, %eax
- cltd
- idivl -8(%rbp)
- movl %eax, _divmod.n(%rip)
+ movl $0, -12(%rbp)
+LBB0_1: ## =>This Inner Loop Header: Depth=1
+ movl -8(%rbp), %eax
+ cmpl -4(%rbp), %eax
+ jge LBB0_3
+## BB#2: ## in Loop: Header=BB0_1 Depth=1
movl -4(%rbp), %eax
- cltd
- idivl -8(%rbp)
- movl %edx, _divmod.n+4(%rip)
- movq -16(%rbp), %rax ## 8-byte Reload
+ subl -8(%rbp), %eax
+ movl %eax, -4(%rbp)
+ movl -12(%rbp), %eax
+ addl $1, %eax
+ movl %eax, -12(%rbp)
+ jmp LBB0_1
+LBB0_3:
+ leaq _divmod.n(%rip), %rax
+ movl -12(%rbp), %ecx
+ movl %ecx, _divmod.n(%rip)
+ movl -4(%rbp), %ecx
+ movl %ecx, _divmod.n+4(%rip)
popq %rbp
retq
.cfi_endproc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment