[Bug middle-end/53776] New: pragma optimize does not support Os
vincenzo.innocente at cern dot ch
gcc-bugzilla@gcc.gnu.org
Tue Jun 26 08:15:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53776
Bug #: 53776
Summary: pragma optimize does not support Os
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vincenzo.innocente@cern.ch
I need to compile optimized for size some portion of code.
The easiest is to "inject" pragmas in the source code at building time
unfortunately Os (and I think also Ofast) are not supported in
pragma optimize (and I think also not by __attribute__)
only numbers works
for instance take
cat optopt.cc
#pragma GCC optimize ("s")
void bar(int);
inline void foo(int i, int j) {
if (i>0) bar(i);
if (j>0) bar(j);
if (i>0) bar(j);
if (j>0) bar(i);
};
void foo1(int i, int j) {
foo(i,j);
}
void foo2(int i, int j) {
foo(i,j);
}
void foo3(int i, int j) {
foo(i,j);
}
c++ -O2 -c optopt.cc; nm -C optopt.o
U bar(int)
0000000000000000 T foo1(int, int)
0000000000000060 T foo2(int, int)
00000000000000c0 T foo3(int, int)
c++ -Os -c optopt.cc; nm -C optopt.o
U bar(int)
0000000000000000 W foo(int, int)
0000000000000000 T foo1(int, int)
0000000000000005 T foo2(int, int)
000000000000000a T foo3(int, int)
with
#pragma GCC optimize ("1")
one gets what intended
c++ -O2 -c optopt.cc; nm -C optopt.o
U bar(int)
0000000000000000 W foo(int, int)
0000000000000000 T foo1(int, int)
0000000000000010 T foo2(int, int)
0000000000000020 T foo3(int, int)
More information about the Gcc-bugs
mailing list