On Thu, Oct 31, 2019 at 09:10:34AM +0100, David Brown wrote: > I think there is a general attitude of "I'm compiling for a small > microcontroller with only 32 KB flash - so I must use flags to make the > code as small as possible". In fact, if you have 32 KB flash then you > need to make your code at most 32 KB in size - code of 31 KB is just as > good as code of 17 KB. As long as your code fits, any further reduction > in size is unnecessary. Yeah, unless you're already at 31kB and now have to add a feature :-) > I haven't reported any "-O2 smaller than -Os" bugs, as far as I can > remember, but have merely noted it as a pattern that I see sometimes. I > will try to keep an eye out for when I see it again. Thanks! > Do you have any reference for the heuristic parameters set by -Os ? (I > am perfectly happy with "it's in this file in the gcc source code", if > that is the answer.) It's not just parameters, it's all over the code: $ grep optimize_[a-z]*_for_ *.c | wc -l 219 $ grep -l optimize_[a-z]*_for_ *.c | wc -l 66 (and that does not include the target code -- there are about 300 more in all targets combined). Segher