Timeline for answer to When did compilers start generating optimized code that runs faster than an average programmer's assembly code? by Cecil Ward
Current License: CC BY-SA 4.0
Post Revisions
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 1, 2023 at 11:29 | comment | added | Sam | One thing that the optimising compiler won't do is self-modifying code so sometimes it's still worth writing some inner loops in assembly if you think you can make use of it. | |
| Oct 21, 2021 at 16:51 | comment | added | supercat |
@smitelli: The choice of whether to use stack vs SI/DI would often depend upon whether variables were declared 'register'. Suitable use of that qualifier can make a huge difference when using Turbo C (and also, incidentally, when using gcc with the -O0 flag). On some occasions, code which makes good use of the register qualifier may be more efficient when compiled with -O0 than it would at any other optimization setting, because using -O0 will prevent gcc from making a counter-productive optimization.
|
|
| Sep 30, 2020 at 20:09 | history | bounty awarded | 15628 | ||
| Sep 26, 2020 at 13:06 | vote | accept | Schezuk | ||
| Sep 15, 2020 at 15:33 | comment | added | supercat | @smitelli: GCC is still like that. When targeting the Cortex-M0, even if code loads a constant into an automatic variable before a loop, and there would be a register available to hold the value throughout the loop, gcc will still sometimes not only apply constant propagation to replace the variable with a constant, and then reload the constant on every iteration of the loop, but even end up adding an extra register move on top of that. | |
| Sep 15, 2020 at 13:42 | comment | added | smitelli |
I spent quite a bit of time looking at output from Borland Turbo C 2.0 (1988) and that compiler varied wildly between smart and dumb. Some tricks (x % 8 -> and ax,7, x = !x -> neg ax; sbb ax,ax; inc ax) were ever-present, but inefficiencies (repetitive wasteful calculations of bx when doing a lot of struct accesses, making bad decisions about stack vs. si/di for frequently-used local vars...) cancelled out the benefit somewhat.
|
|
| Sep 14, 2020 at 20:54 | comment | added | Cody Gray | Watcom had a truly fantastic optimizer by the early-to-mid 1990s that I would have put up against almost any assembly language programmer, but I wasn't using their original tools from the late 1980s, so I didn't know if it was always so awesome. | |
| Sep 13, 2020 at 19:50 | review | First posts | |||
| Sep 13, 2020 at 20:18 | |||||
| Sep 13, 2020 at 19:46 | history | answered | Cecil Ward | CC BY-SA 4.0 |