https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118356

--- Comment #8 from Javier Mora <cousteaulecommandant at gmail dot com> ---
(In reply to Jeffrey A. Law from comment #7)
> For example, deeply embedded where
> codesize is particularly important likely won't want any code alignments. 
> While other uarchs (say targetting a server market) are going to be more
> likely to want code alignments to improve performance, even if it means
> slightly larger codesize.

I understand that would be the kind of situation where one chooses between -Os
or -O2 (or 3), depending on whether they want to optimize for size or
performance.

Note that -O2 will enable the -falign-* flags, without specifying a value,
meaning to let the compiler choose the "standard" alignment when alignment is
requested but its value is not specified, whereas -Os will not enable that flag
so alignment will not be enforced at all, even if the "default value" for
-falign-* when the flag is used is 4 (if I understood the documentation right).
 So, in this regard, I wouldn't worry about "what will the end user typically
want with each specific uarch" because that's what -O2 and -Os are for; the
only thing to do is to provide a set of reasonable parameters for those two
options (which, in the case of CVE4 and other uarchs, involves enabling a jump
alignment of 4 for better performance, or disabling it for smaller code size).

But I understand that -O2 shouldn't "always align jumps at the cost of code
size just in case this program ever runs in this or that microarchitecture",
because as it has been discussed, this might mean worse code size for zero
speed increase on certain uarchs, so I agree that perhaps this should be a
uarch-specific tweak rather than a global setting.  But it is clear to me it
has to be added to the CVE4 family, regardless of what its application will be,
or whether this will go in an embedded system or a large server, since enabling
this alignment does indeed make the code faster (at the cost of larger code
size), so it should be enabled when the user selects the option to "enable
optimizations that make the code faster at the cost of larger code size".

Reply via email to