Undocumented optimization flag, switched by O1

preineke@mail.uni-paderborn.de preineke@mail.uni-paderborn.de
Tue Nov 20 17:32:00 GMT 2007


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





More information about the Gcc-help mailing list