public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* list of optimizations done by -O1 level
@ 2007-02-22 16:49 ranjith kumar
  2007-02-22 16:56 ` Ian Lance Taylor
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: ranjith kumar @ 2007-02-22 16:49 UTC (permalink / raw)
  To: gcc-help

Hi,
 GCC manuals says the foloowing are the list of
optimizations turned on when -O1 flag is used.
-------------------------------------------------------
 -fdefer-pop -fdelayed-branch       
-fguess-branch-probability -fcprop-registers
-floop-optimize -fif-conversion
           -fif-conversion2 -ftree-ccp -ftree-dce
-ftree-dominator-opts -ftree-dse
           -ftree-ter -ftree-lrs -ftree-sra
-ftree-copyrename -ftree-fre -ftree-ch
           -fmerge-constants
           -O also turns on -fomit-frame-pointer on
machines where doing so does not
           interfere with debugging.

           -O doesnÂ’t turn on -ftree-sra for the Ada
compiler.  This option must be
           explicitly specified on the command line to
be enabled for the Ada compiler.
----------------------------------------------------

But When I compiled the same file as in the following
2 ways, I got two differen assembly programs. What
could be the reason. 
Thanks in advance.


1) gcc -march=pentium4 -O1 -S res22.c
2) gcc -march=pentium4 -fdefer-pop -fdelayed-branch   
    -fguess-branch-probability -fcprop-registers
-floop-optimize -fif-conversion
           -fif-conversion2 -ftree-ccp -ftree-dce
-ftree-dominator-opts -ftree-dse
           -ftree-ter -ftree-lrs -ftree-sra
-ftree-copyrename -ftree-fre -ftree-ch
           -fmerge-constants -fomit-frame-pointer
-ftree-sra 
  -S res22.c
Are there any extra optimizations turned on while
using -O1 options???????????????
Below is the res22.c program.
-------------------------------------------------------
-------------------------------------------------------
 1 #include <stdio.h>
      2 #include <xmmintrin.h>
      3  unsigned  int x , y,p,val,x1;
      4
      5 __m128 a, b, c;
      6
      7 float inp_sse1[4] __attribute__((aligned(16)))
= { 1.2, 3.5, 1.7, 2.8 };
      8 float inp_sse2[4]
__attribute__((aligned(16)))= { -0.7, 2.6, 3.3, -4.0
};
      9 float out_sse[4] __attribute__((aligned(16)));
     10 void f()
     11 {
     12
     13    c = _mm_add_ps(a, b);
     14    _mm_store_ps(out_sse,c);
     15 }
     16
     17
     18 int main(void){
     19  int i,j;
     20
     21 a = _mm_load_ps(inp_sse1);
     22    b = _mm_load_ps(inp_sse2);
     23
     24 //for(j=0;j<999;j++)
     25 //  for(i = 0; i < 9999; i++)
     26 f();
     27
     28 for(i = 0; i < 4; i++) {
     29     printf("Result %d: %.2f\n",i,out_sse[i]);
     30 }



		
___________________________________________________________ 
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 

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

* Re: list of optimizations done by -O1 level
  2007-02-22 16:49 list of optimizations done by -O1 level ranjith kumar
@ 2007-02-22 16:56 ` Ian Lance Taylor
  2007-02-22 17:27   ` ranjith kumar
  2007-02-22 17:01 ` Daniel Lohmann
  2007-02-22 17:24 ` John Love-Jensen
  2 siblings, 1 reply; 9+ messages in thread
From: Ian Lance Taylor @ 2007-02-22 16:56 UTC (permalink / raw)
  To: ranjith kumar; +Cc: gcc-help

ranjith kumar <ranjit_kumar_b4u@yahoo.co.uk> writes:

>  GCC manuals says the foloowing are the list of
> optimizations turned on when -O1 flag is used.
> -------------------------------------------------------
>  -fdefer-pop -fdelayed-branch       
> -fguess-branch-probability -fcprop-registers
> -floop-optimize -fif-conversion
>            -fif-conversion2 -ftree-ccp -ftree-dce
> -ftree-dominator-opts -ftree-dse
>            -ftree-ter -ftree-lrs -ftree-sra
> -ftree-copyrename -ftree-fre -ftree-ch
>            -fmerge-constants
>            -O also turns on -fomit-frame-pointer on
> machines where doing so does not
>            interfere with debugging.
> 
>            -O doesn’t turn on -ftree-sra for the Ada
> compiler.  This option must be
>            explicitly specified on the command line to
> be enabled for the Ada compiler.
> ----------------------------------------------------

The gcc manual also says:

    Not all optimizations are controlled directly by a flag.  Only
    optimizations that have a flag are listed.

Ian

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

* Re: list of optimizations done by -O1 level
  2007-02-22 16:49 list of optimizations done by -O1 level ranjith kumar
  2007-02-22 16:56 ` Ian Lance Taylor
@ 2007-02-22 17:01 ` Daniel Lohmann
  2007-02-22 17:24 ` John Love-Jensen
  2 siblings, 0 replies; 9+ messages in thread
From: Daniel Lohmann @ 2007-02-22 17:01 UTC (permalink / raw)
  To: ranjith kumar; +Cc: gcc-help

ranjith kumar schrieb:
> Hi,
>  GCC manuals says the foloowing are the list of
> optimizations turned on when -O1 flag is used.
> ...
> 
> But When I compiled the same file as in the following
> 2 ways, I got two differen assembly programs. What
> could be the reason. 

Besides the explicit set of optimizations, there is also a general 
optimize-flag used within gcc. This flag is set by the -O option itself.

Daniel

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

* Re: list of optimizations done by -O1 level
  2007-02-22 16:49 list of optimizations done by -O1 level ranjith kumar
  2007-02-22 16:56 ` Ian Lance Taylor
  2007-02-22 17:01 ` Daniel Lohmann
@ 2007-02-22 17:24 ` John Love-Jensen
  2 siblings, 0 replies; 9+ messages in thread
From: John Love-Jensen @ 2007-02-22 17:24 UTC (permalink / raw)
  To: ranjith kumar, MSX to GCC

Hi Ranjith,

I don't have an answer to your inquiry, but here's a helpful trick to answer
the "Hmmm, I wonder what flags are controlled by the optimization level
flags?" ...

echo '' | g++     -fverbose-asm -S -x c++ - -o blank.s
echo '' | g++ -O0 -fverbose-asm -S -x c++ - -o O0.s
echo '' | g++ -O1 -fverbose-asm -S -x c++ - -o O1.s
echo '' | g++ -O2 -fverbose-asm -S -x c++ - -o O2.s
echo '' | g++ -O3 -fverbose-asm -S -x c++ - -o O3.s
echo '' | g++ -Os -fverbose-asm -S -x c++ - -o Os.s

Note: there are optimizations above-and-beyond the ones that are
identifiable by a specific named flag.

HTH,
--Eljay


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

* Re: list of optimizations done by -O1 level
  2007-02-22 16:56 ` Ian Lance Taylor
@ 2007-02-22 17:27   ` ranjith kumar
  2007-02-22 17:39     ` Andrew Haley
  2007-02-23  8:34     ` Christopher Layne
  0 siblings, 2 replies; 9+ messages in thread
From: ranjith kumar @ 2007-02-22 17:27 UTC (permalink / raw)
  To: Ian Lance Taylor, gcc-help


--- Ian Lance Taylor <iant@google.com> wrote:

> ranjith kumar <ranjit_kumar_b4u@yahoo.co.uk> writes:
> 
> >  GCC manuals says the foloowing are the list of
> > optimizations turned on when -O1 flag is used.
> >
>
-------------------------------------------------------
> >  -fdefer-pop -fdelayed-branch       
> > -fguess-branch-probability -fcprop-registers
> > -floop-optimize -fif-conversion
> >            -fif-conversion2 -ftree-ccp -ftree-dce
> > -ftree-dominator-opts -ftree-dse
> >            -ftree-ter -ftree-lrs -ftree-sra
> > -ftree-copyrename -ftree-fre -ftree-ch
> >            -fmerge-constants
> >            -O also turns on -fomit-frame-pointer
> on
> > machines where doing so does not
> >            interfere with debugging.
> > 
> >            -O doesnÂ’t turn on -ftree-sra for the
> Ada
> > compiler.  This option must be
> >            explicitly specified on the command
> line to
> > be enabled for the Ada compiler.
> >
> ----------------------------------------------------
> 
> The gcc manual also says:
> 
>     Not all optimizations are controlled directly by
> a flag.  Only
>     optimizations that have a flag are listed.
> 
> Ian
> 
Sorry. What do you mean?


Is there any way to find list of optimizations enabled
by -O1?

Actually when I explicitly specified  all
optimizations, there were function calls associated
with each SIMD function called in .c file.
But when I used -O1 flag they were not present in
assembly code.
I am intrested in knowing which optimization is
replacing those function calls and at what
intermediate representation that optimization is done?

Thanks.



	
	
		
___________________________________________________________ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 

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

* Re: list of optimizations done by -O1 level
  2007-02-22 17:27   ` ranjith kumar
@ 2007-02-22 17:39     ` Andrew Haley
  2007-02-22 19:55       ` ranjith kumar
  2007-02-23  8:34     ` Christopher Layne
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Haley @ 2007-02-22 17:39 UTC (permalink / raw)
  To: ranjith kumar; +Cc: Ian Lance Taylor, gcc-help

ranjith kumar writes:
 > 
 > 
 > Is there any way to find list of optimizations enabled
 > by -O1?

-fverbose-asm.  The list is in the top of the .s file.

 > Actually when I explicitly specified  all
 > optimizations, there were function calls associated
 > with each SIMD function called in .c file.
 > But when I used -O1 flag they were not present in
 > assembly code.
 > I am intrested in knowing which optimization is
 > replacing those function calls and at what
 > intermediate representation that optimization is done?

Use -fdump-tree-all and have a look.

Andrew.

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

* Re: list of optimizations done by -O1 level
  2007-02-22 17:39     ` Andrew Haley
@ 2007-02-22 19:55       ` ranjith kumar
  2007-02-22 23:10         ` Andrew Haley
  0 siblings, 1 reply; 9+ messages in thread
From: ranjith kumar @ 2007-02-22 19:55 UTC (permalink / raw)
  To: Andrew Haley, gcc-help


--- Andrew Haley <aph@redhat.com> wrote:

> ranjith kumar writes:
>  > 
>  > 
>  > Is there any way to find list of optimizations
> enabled
>  > by -O1?
> 
> -fverbose-asm.  The list is in the top of the .s
> file.
No. That option shows some list of optimizations.
But when I compiled with all those list of
optimizations instead of -O1, the effetct was not
same.
Any help please.
> 
>  > Actually when I explicitly specified  all
>  > optimizations, there were function calls
> associated
>  > with each SIMD function called in .c file.
>  > But when I used -O1 flag they were not present in
>  > assembly code.
>  > I am intrested in knowing which optimization is
>  > replacing those function calls and at what
>  > intermediate representation that optimization is
> done?
> 
> Use -fdump-tree-all and have a look.
> 
> Andrew.
> 



		
___________________________________________________________ 
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html

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

* Re: list of optimizations done by -O1 level
  2007-02-22 19:55       ` ranjith kumar
@ 2007-02-22 23:10         ` Andrew Haley
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Haley @ 2007-02-22 23:10 UTC (permalink / raw)
  To: ranjith kumar; +Cc: gcc-help

ranjith kumar writes:
 > 
 > --- Andrew Haley <aph@redhat.com> wrote:
 > 
 > > ranjith kumar writes:
 > >  > 
 > >  > 
 > >  > Is there any way to find list of optimizations
 > > enabled
 > >  > by -O1?
 > > 
 > > -fverbose-asm.  The list is in the top of the .s
 > > file.
 > No. That option shows some list of optimizations.

It is the list of optimization passes that were run.

 > But when I compiled with all those list of
 > optimizations instead of -O1, the effetct was not
 > same.

Quite a lot of optimizations are controlled by "if (optimize)",
regardless of what list of passes was supplied.  

There is no list of optimizations that you can supply to gcc that will
replicate the effect of -O1.

Andrew.

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

* Re: list of optimizations done by -O1 level
  2007-02-22 17:27   ` ranjith kumar
  2007-02-22 17:39     ` Andrew Haley
@ 2007-02-23  8:34     ` Christopher Layne
  1 sibling, 0 replies; 9+ messages in thread
From: Christopher Layne @ 2007-02-23  8:34 UTC (permalink / raw)
  To: ranjith kumar; +Cc: Ian Lance Taylor, gcc-help

On Thu, Feb 22, 2007 at 05:24:07PM +0000, ranjith kumar wrote:
> Is there any way to find list of optimizations enabled
> by -O1?
> 
> Actually when I explicitly specified  all
> optimizations, there were function calls associated
> with each SIMD function called in .c file.
> But when I used -O1 flag they were not present in
> assembly code.

And you did not use -msse -msse2 or -mtune=x at the same time as specifying
the other flags?

-cl

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

end of thread, other threads:[~2007-02-23  4:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-22 16:49 list of optimizations done by -O1 level ranjith kumar
2007-02-22 16:56 ` Ian Lance Taylor
2007-02-22 17:27   ` ranjith kumar
2007-02-22 17:39     ` Andrew Haley
2007-02-22 19:55       ` ranjith kumar
2007-02-22 23:10         ` Andrew Haley
2007-02-23  8:34     ` Christopher Layne
2007-02-22 17:01 ` Daniel Lohmann
2007-02-22 17:24 ` John Love-Jensen

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