I don't have a reliable tool to measure the time taken to execute one or more instructions.
This is just to keep track of the assembly output for different C expressions.
The assembly is in AT&T syntax, but the comments will be written in Intel syntax as GitHub Markdown does not support AT&T syntax.
GCC with -O3
optimizes the following code
unsigned times10(unsigned n) {
return n * 10;
}
into
leal (%rdi,%rdi,4), %eax
addl %eax, %eax
Total 2 instructions
GCC with -O3
optimizes the following code
unsigned divides10(unsigned n) {
return n / 10;
}
into
movl %edi, %eax
movl $3435973837, %edx
imulq %rdx, %rax
shrq $35, %rax
This article will be updated from time to time.