public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/53776] New: pragma optimize does not support Os
@ 2012-06-26  8:15 vincenzo.innocente at cern dot ch
  2012-06-26  8:43 ` [Bug middle-end/53776] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-06-26  8:15 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-23  4:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-26  8:15 [Bug middle-end/53776] New: pragma optimize does not support Os vincenzo.innocente at cern dot ch
2012-06-26  8:43 ` [Bug middle-end/53776] " pinskia at gcc dot gnu.org
2012-06-26  8:58 ` rguenth at gcc dot gnu.org
2021-08-12  5:41 ` pinskia at gcc dot gnu.org
2021-11-29  6:47 ` pinskia at gcc dot gnu.org
2021-12-23  4:11 ` [Bug ipa/53776] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).