public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Undocumented optimization flag, switched by O1
@ 2007-11-20 17:32 preineke
  2007-11-21  4:20 ` John (Eljay) Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: preineke @ 2007-11-20 17:32 UTC (permalink / raw)
  To: gcc-help

Hi

I am trying to run a C/C++ project for the PowerPC with GCC 4.2.2 with  
optimization O1 enabled. While it runs perfectly without, it fails if  
-O1 is enabled.
Trying to isolate the harmful optimization, i tried to specify all  
flags which are enabled with O1, one by one.

My invocations look now like this:
/usr/local/powerpc-eabi/bin/powerpc-eabi-gcc -c test.c -o testNO1.o  
-fdefer-pop -fomit-frame-pointer -fguess-branch-probability  
-fcprop-registers -fif-conversion -fif-conversion2 -fipa-pure-const  
-fipa-reference -ftree-ccp -ftree-dce -ftree-dominator-opts   
-ftree-dse -ftree-ter  -ftree-lrs -ftree-sra -ftree-copyrename  
-ftree-fre -ftree-copy-prop -ftree-sink -ftree-salias -funit-at-a-time  
-ftree-ch
/usr/local/powerpc-eabi/bin/powerpc-eabi-gcc -c test.c -o testO1.o -O1

In addition to the options listed in the manual as options used by -O1  
I also included -ftree-sink -ftree-salias, which are mentioned in the  
manual but not in the list, and -fipa-pure-const -fipa-reference,  
which are not documented but apparently set (see  
http://gcc.gnu.org/viewcvs/tags/gcc_4_2_2_release/gcc/opts.c?view=markup - as  
there is no "unrecognized command line" error i guess i specified them  
correctly).

But still the output files differ.
Does anyone know which optimizations may be used additionally and  
whether i can  toggle them manually?

Regards.

Peter


The test.c looks like this:

extern void bar(int x);

foo(int x)
{
     bar(x);
}

The resultings disassemblies are:

testNO1.o:     file format elf32-powerpc

Disassembly of section .text:

00000000 <foo>:
    0:	94 21 ff f0 	stwu    r1,-16(r1)
    4:	7c 08 02 a6 	mflr    r0
    8:	90 01 00 14 	stw     r0,20(r1)
    c:	90 61 00 08 	stw     r3,8(r1)
   10:	80 61 00 08 	lwz     r3,8(r1)
   14:	48 00 00 01 	bl      14 <foo+0x14>
   18:	80 01 00 14 	lwz     r0,20(r1)
   1c:	7c 08 03 a6 	mtlr    r0
   20:	38 21 00 10 	addi    r1,r1,16
   24:	4e 80 00 20 	blr

testO1.o:     file format elf32-powerpc

Disassembly of section .text:

00000000 <foo>:
    0:	94 21 ff f8 	stwu    r1,-8(r1)
    4:	7c 08 02 a6 	mflr    r0
    8:	90 01 00 0c 	stw     r0,12(r1)
    c:	48 00 00 01 	bl      c <foo+0xc>
   10:	80 01 00 0c 	lwz     r0,12(r1)
   14:	7c 08 03 a6 	mtlr    r0
   18:	38 21 00 08 	addi    r1,r1,8
   1c:	4e 80 00 20 	blr



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

* RE: Undocumented optimization flag, switched by O1
  2007-11-20 17:32 Undocumented optimization flag, switched by O1 preineke
@ 2007-11-21  4:20 ` John (Eljay) Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: John (Eljay) Love-Jensen @ 2007-11-21  4:20 UTC (permalink / raw)
  To: preineke, gcc-help

Hi Peter,

Please keep in mind that -O1 enables a lot of optimizations.

Some of those optimizations can be disabled using a -f switch.

To view the -f flags enabled by -O1 use this handy tip:

  gcc -fverbose-asm -H -x c <(echo '') -O1 -S -o O1.s

You can then try disabling the -f optimizations until you find your culprit.  Divide & conquer would be the fastest way to zero in on the problem optimization.

CAVEAT, not all optimizations enabled by -O1 have a command-line toggle flag to disable them.

Also important to know, that with -O0 no optimizations are performed, regardless of the -f flags enabled.  The -O0 squelches all optimzations.  If no optimization level is explicitly specified, -O0 is the default.  So I don't think your "enabling optimizations flag-by-flag" had the results you were looking for.

HTH,
--Eljay

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

end of thread, other threads:[~2007-11-20 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-20 17:32 Undocumented optimization flag, switched by O1 preineke
2007-11-21  4:20 ` John (Eljay) 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).