public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc compile for code size
@ 2012-11-11 19:47 Xin Tong
  2012-11-11 19:54 ` Andrew Haley
  0 siblings, 1 reply; 6+ messages in thread
From: Xin Tong @ 2012-11-11 19:47 UTC (permalink / raw)
  To: gcc-help

when gcc is set to compile for minimal code size, what kind of
optimizations does gcc apply in comparison to compile for performance
? or it is just gcc spends more time doing the compilation, selecting
instruction sequences that are optimal for code size.

Xin

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

* Re: gcc compile for code size
  2012-11-11 19:47 gcc compile for code size Xin Tong
@ 2012-11-11 19:54 ` Andrew Haley
  2012-11-11 19:59   ` Xin Tong
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Haley @ 2012-11-11 19:54 UTC (permalink / raw)
  To: Xin Tong; +Cc: gcc-help

On 11/11/2012 07:47 PM, Xin Tong wrote:
> when gcc is set to compile for minimal code size, what kind of
> optimizations does gcc apply in comparison to compile for performance
> ? or it is just gcc spends more time doing the compilation, selecting
> instruction sequences that are optimal for code size.

No.  GCC does all optimizations *except* those known to increase
program size.  This usually works pretty well, but isn't perfect.

Andrew.

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

* Re: gcc compile for code size
  2012-11-11 19:54 ` Andrew Haley
@ 2012-11-11 19:59   ` Xin Tong
  2012-11-11 21:01     ` Andrew Haley
  0 siblings, 1 reply; 6+ messages in thread
From: Xin Tong @ 2012-11-11 19:59 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-help

so as to how the instructions are selected. compiling for code size
does not have an effect ?

Xin


On Sun, Nov 11, 2012 at 2:54 PM, Andrew Haley <aph@redhat.com> wrote:
> On 11/11/2012 07:47 PM, Xin Tong wrote:
>> when gcc is set to compile for minimal code size, what kind of
>> optimizations does gcc apply in comparison to compile for performance
>> ? or it is just gcc spends more time doing the compilation, selecting
>> instruction sequences that are optimal for code size.
>
> No.  GCC does all optimizations *except* those known to increase
> program size.  This usually works pretty well, but isn't perfect.
>
> Andrew.
>

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

* Re: gcc compile for code size
  2012-11-11 19:59   ` Xin Tong
@ 2012-11-11 21:01     ` Andrew Haley
  2012-11-11 21:09       ` Jeff Law
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Haley @ 2012-11-11 21:01 UTC (permalink / raw)
  To: Xin Tong; +Cc: gcc-help

On 11/11/2012 07:59 PM, Xin Tong wrote:

> On Sun, Nov 11, 2012 at 2:54 PM, Andrew Haley <aph@redhat.com> wrote:
>> On 11/11/2012 07:47 PM, Xin Tong wrote:
>>> when gcc is set to compile for minimal code size, what kind of
>>> optimizations does gcc apply in comparison to compile for performance
>>> ? or it is just gcc spends more time doing the compilation, selecting
>>> instruction sequences that are optimal for code size.
>>
>> No.  GCC does all optimizations *except* those known to increase
>> program size.  This usually works pretty well, but isn't perfect.
>>
> so as to how the instructions are selected. compiling for code size
> does not have an effect ?

Please don't top-post on this list.

Any target could, in principle, select instructions based on size
and -OS, but I don't know any that do.

Andrew.

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

* Re: gcc compile for code size
  2012-11-11 21:01     ` Andrew Haley
@ 2012-11-11 21:09       ` Jeff Law
  2012-11-11 21:32         ` Andrew Haley
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Law @ 2012-11-11 21:09 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Xin Tong, gcc-help

On 11/11/2012 02:01 PM, Andrew Haley wrote:
> On 11/11/2012 07:59 PM, Xin Tong wrote:
>>> No.  GCC does all optimizations *except* those known to increase
>>> program size.  This usually works pretty well, but isn't perfect.
>>>
>> so as to how the instructions are selected. compiling for code size
>> does not have an effect ?
>
> Please don't top-post on this list.
>
> Any target could, in principle, select instructions based on size
> and -OS, but I don't know any that do.
Many ports look at at -Os and change their instruction selections, 
alignment requests, etc.

grep for "optimize_size" in the machine descriptions...

jeff

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

* Re: gcc compile for code size
  2012-11-11 21:09       ` Jeff Law
@ 2012-11-11 21:32         ` Andrew Haley
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Haley @ 2012-11-11 21:32 UTC (permalink / raw)
  To: Jeff Law; +Cc: Xin Tong, gcc-help

On 11/11/2012 09:08 PM, Jeff Law wrote:
> On 11/11/2012 02:01 PM, Andrew Haley wrote:
>> On 11/11/2012 07:59 PM, Xin Tong wrote:
>>>> No.  GCC does all optimizations *except* those known to increase
>>>> program size.  This usually works pretty well, but isn't perfect.
>>>>
>>> so as to how the instructions are selected. compiling for code size
>>> does not have an effect ?
>>
>> Please don't top-post on this list.
>>
>> Any target could, in principle, select instructions based on size
>> and -OS, but I don't know any that do.
> Many ports look at at -Os and change their instruction selections, 
> alignment requests, etc.
> 
> grep for "optimize_size" in the machine descriptions...

Oops, sorry.  While "I don't know" was true, it wasn't very helpful.
I do now!

Andrew.


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

end of thread, other threads:[~2012-11-11 21:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-11 19:47 gcc compile for code size Xin Tong
2012-11-11 19:54 ` Andrew Haley
2012-11-11 19:59   ` Xin Tong
2012-11-11 21:01     ` Andrew Haley
2012-11-11 21:09       ` Jeff Law
2012-11-11 21:32         ` Andrew Haley

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).