- controls calculations:
- flag "flush to zero" (described later)
- flag "denormals are zeros" (described later)
- rounding mode (not covered in this text)
- allow to mask/unmask floating-point exceptions
- save information about floating-point errors - these flags are sticky, i.e. the programmer is responsible for clearing them.
niedziela, 26 stycznia 2014
Penalties of errors in SSE floating point calculations
SSE provides not widely known control register, called MXCSR. This register plays three roles:
środa, 1 stycznia 2014
x86 - ISA where 80% of instructons are unimportant
Few years ago I counted instructions from many Linux binaries --- 2014 is good year to repeated this experiment and see that nothing has changed.
I use 32-bit Debian, my installation has been updated few months ago. All files from /usr/bin and all *.so files from /usr/lib was disassembled with objdump (5050 files were processed). Instructions were grouped simply by mnemonic name, taking into account all addressing and encoding modes would be overkill. I've published script that does the job.
Short summary
- Number of distinct decoded instructions is around 650. Since objdump use AT&T syntax, same opcode is seen under different mnemonics, for example mov is saved as movw, movb, movl depending on argument size.
- Total number of x86 instructions is around 750. Read: one hundred instructions never appeared in the binaries.
- There are 81 instructions used just once. For example quite useful CMPPD.
- There are 22 instructions used twice. For example MFENCE --- no one aware of memory ordering?
- There are 15 instructions used three times. For example BTC, but bit manipulating operations are useless.
- 81 plus 22 plus 15 is 118. Another hundred of useless stuff.
- The total count of these instructions is 87.84% of all instructions (almost all, isn't it?).
- The most frequently used instruction is data transfer (mov/movl) --- 42%
- Control flow instructions (call/ret/jmp) --- 13%.
- Conditions (cmp/test/condition jumps: je/jne) --- 10%.
- Basic arithmetic (add/sub/lea) --- 12%
- Simple stack operations (push/pop) --- 6%
Very interesting observation is that conditions are mostly based on je/jne, i.e. jump if zero/jump if not zero.
First FPU instruction appear at 28-th position. First integer SSE appear at 167-th position. First SSE instruction operating on packed floats appear at 315-th position.
Detailed results
Whole table as txt file.instruction | count | % |
---|---|---|
mov | 5934098 | 37.63% |
call | 1414355 | 8.97% |
lea | 1071501 | 6.79% |
movl | 760677 | 4.82% |
push | 655921 | 4.16% |
jmp | 611540 | 3.88% |
add | 560517 | 3.55% |
je | 490250 | 3.11% |
test | 475899 | 3.02% |
pop | 441608 | 2.80% |
sub | 366228 | 2.32% |
cmp | 326379 | 2.07% |
jne | 264110 | 1.67% |
nop | 242356 | 1.54% |
ret | 238569 | 1.51% |
xor | 148194 | 0.94% |
movzbl | 122730 | 0.78% |
and | 88863 | 0.56% |
xchg | 66885 | 0.42% |
cmpl | 64907 | 0.41% |
movzwl | 64589 | 0.41% |
movb | 57247 | 0.36% |
or | 52138 | 0.33% |
shl | 50908 | 0.32% |
cmpb | 50152 | 0.32% |
jle | 41083 | 0.26% |
leave | 39923 | 0.25% |
fldl | 37428 | 0.24% |
fstpl | 37368 | 0.24% |
shr | 36503 | 0.23% |
jbe | 32866 | 0.21% |
ja | 32333 | 0.21% |
sar | 30917 | 0.20% |
flds | 29672 | 0.19% |
subl | 27636 | 0.18% |
setne | 27626 | 0.18% |
testb | 27420 | 0.17% |
addl | 25906 | 0.16% |
imul | 25569 | 0.16% |
jg | 24796 | 0.16% |
fstp | 24349 | 0.15% |
fxch | 23464 | 0.15% |
js | 21550 | 0.14% |
fstps | 21248 | 0.13% |
sbb | 16607 | 0.11% |
inc | 16200 | 0.10% |
lock | 16049 | 0.10% |
jae | 14825 | 0.09% |
sahf | 14765 | 0.09% |
dec | 14276 | 0.09% |
fnstsw | 14026 | 0.09% |
sete | 13902 | 0.09% |
movw | 13895 | 0.09% |
adc | 13640 | 0.09% |
jb | 12467 | 0.08% |
jl | 11700 | 0.07% |
repz | 11178 | 0.07% |
fldcw | 11110 | 0.07% |
jge | 11019 | 0.07% |
movswl | 10816 | 0.07% |
fildl | 8852 | 0.06% |
cmpw | 7601 | 0.05% |
jns | 7490 | 0.05% |
fldz | 7331 | 0.05% |
fmul | 7229 | 0.05% |
out | 7203 | 0.05% |
not | 7028 | 0.04% |
movsbl | 6720 | 0.04% |
in | 6503 | 0.04% |
fld | 6309 | 0.04% |
faddp | 6254 | 0.04% |
fstl | 5760 | 0.04% |
fucom | 5753 | 0.04% |
neg | 5725 | 0.04% |
fucompp | 5354 | 0.03% |
rep | 5059 | 0.03% |
fmuls | 5039 | 0.03% |
pushl | 4430 | 0.03% |
jp | 4424 | 0.03% |
fnstcw | 4400 | 0.03% |
fld1 | 4176 | 0.03% |
fmulp | 4133 | 0.03% |
orl | 3927 | 0.02% |
fadds | 3789 | 0.02% |
movq | 3779 | 0.02% |
fistpl | 3709 | 0.02% |
cltd | 3597 | 0.02% |
fmull | 3313 | 0.02% |
stos | 3298 | 0.02% |
lret | 3183 | 0.02% |
scas | 3103 | 0.02% |
lods | 3066 | 0.02% |
cwtl | 3064 | 0.02% |
fadd | 2852 | 0.02% |
fucomp | 2678 | 0.02% |
orb | 2481 | 0.02% |
fildll | 2418 | 0.02% |
andl | 2379 | 0.02% |
setb | 2337 | 0.01% |
andb | 2263 | 0.01% |
552 rows more... |