4 ms·
Aren't most optimisations hardware dependant, and if so: wouldn't it make sense that the work put into these optimisations depends largely on how much the hardw
by vanderZwan 14y ago
Aren't most optimisations hardware dependant, and if so: wouldn't it make sense that the work put into these optimisations depends largely on how much the hardware is used? Is the PDP-11 still a useful target in that sense? Wouldn't the original x86 instruction set be more useful for example?
- 1337p337 14y agoThe situation with x86 specifically is a little weirder than that: http://www.emulators.com/docs/nx06_rmw.htm http://www.emulators.com/docs/nx06_rmw.htm . It's a bit of a long read, but the summary is that on some x86s, single-instruction adds to memory are faster, and on others, load/increment/store in three instructions is faster. Compiler optimization be a harsh mistress.
- kragen 14y agoWell, if you want to compare a 1970s compiler to a modern compiler, the x86 instruction set will not be a useful target, since no 1970s compilers target it. These particular ancient compilers target the PDP-11. The larger question of whether optimizations are hardware-dependent is interesting. In some sense, sure. But there are a lot of optimizations in modern compilers that apply equally well to the PDP-11 and to the AMD64; they're just not that different. My homework assignment for you: write a C function of three or four lines which loops over an array of structs and does some computation for each one, including some conditional and a call to a one-line static function; compile it with -c -O0 -Wa,-adhlns=unoptimized.lst and with -c -O5 -fomit-frame-pointer -Wa,-adhlns=optimized.lst; list the optimizations you notice in the difference between unoptimized.lst, and hazard a guess at which of them are applicable on a PDP-11.