|
|
Subscribe / Log in / New account

Looking forward to GCC 7

Looking forward to GCC 7

Posted Apr 7, 2017 21:37 UTC (Fri) by ncm (guest, #165)
In reply to: Looking forward to GCC 7 by zlynx
Parent article: Looking forward to GCC 7

When I last looked, the policy was that, by default, the compiler should generate code that runs correctly on the widest variety of released hardware (i.e. the smallest common instruction set), but is tuned for the latest, fastest chips. This makes sense, in that users who are most interested in performance have the newest hardware, and anybody who wants better performance actually gets it by buying the new hardware and running the program as built with the newest compiler. I don't think that policy changed.

So, inserting instructions between the test and the branch pessimizes current hardware, by default, in exchange for possibly less-bad performance on very old, slow hardware that (manifestly) nobody cares about enough to upgrade. It seems more likely to me that nobody on the project has reviewed the particular choice to insert the instructions, in light of current developments. In fact, when I last checked (in 6.1, I think), telling gcc to tune for Haswell did not make it emit fusible test-and-branch sequences.

But I would be interested to learn about a change in the policy, if any, and what motivated it.


to post comments

Looking forward to GCC 7

Posted Apr 7, 2017 22:30 UTC (Fri) by excors (subscriber, #95769) [Link] (1 responses)

GCC does seem to have code for macro fusion like that, added in GCC 4.9.0, so it probably ought to work.

Looking forward to GCC 7

Posted Apr 8, 2017 3:18 UTC (Sat) by ncm (guest, #165) [Link]

That is an unusually large source file by any standard.

Looking forward to GCC 7

Posted Apr 10, 2017 11:39 UTC (Mon) by joib (subscriber, #8541) [Link] (1 responses)

The default policy is to do no optimization at all. However, these days most Linux distros AFAIK use something like "-O2 -g -mtune=generic" as their default CFLAGS, which should roughly accomplish what you say.

One could argue that by default GCC should a) do some optimizations b) generate debug symbols, and though I agree with that sentiment, it's another topic.

If GCC missed the opportunity for macro-op fusion with -mtune=generic, that sounds like a missed optimization bug.

Looking forward to GCC 7

Posted Apr 10, 2017 12:55 UTC (Mon) by pabs (subscriber, #43278) [Link]

GCC should also enable some of the hardening flags by default. It is pretty silly that every distro has to do that manually.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds