3 ms·
These are very early compilers indeed, but it makes me wonder: a HN comment today reminded me of 'Proebsting's law' that compilers double program speed every 18
by gwern 14y ago
These are very early compilers indeed, but it makes me wonder: a HN comment today reminded me of 'Proebsting's law' that compilers double program speed every 18 years. He got this by comparing a -O0 run with a -02 run and then dividing, but the obvious problem with this is that even if a modern compiler is run with -O0 it's probably going to be in effect optimizing a lot just by all the architectural choices and default code generation. It would be interesting to see if one could take a more recent C compiler, say late '70s and compare it to a heavily optimizing GCC run, and answer the question: how much have C compilers improved over the last 30-40 years?
- kragen 14y agoI am pleasantly surprised to see that current GCC seems to be able to generate code for a PDP-11 target. I think there may actually even be cycle-accurate PDP-11 simulators around, which would enable you to do the benchmarking. If you do get around to it, I'd love to hear your results!
- vanderZwan 14y agoAren'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.