public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/53776] New: pragma optimize does not support Os
Date: Tue, 26 Jun 2012 08:15:00 -0000	[thread overview]
Message-ID: <bug-53776-4@http.gcc.gnu.org/bugzilla/> (raw)

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)


             reply	other threads:[~2012-06-26  8:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26  8:15 vincenzo.innocente at cern dot ch [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-53776-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).