forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GCC optimisation issues.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Sep 20, 2004 5:12 pm    Post subject: GCC optimisation issues. Reply with quote

Hello,

I wasn't that much aware that the compiler's -O option was so buggy. That is true that I usually do not test my softwares using that option. Now, please, people, do NOT use -O at all :)

Even better: developp your softwares without any -O, and then, when it seems to be stable enough, retry with various -O settings (3 will most likely hit the 128-bits alignment bug, beware), and please report strange behaviors caused by optimisation option.

Thanks ;)
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Sep 20, 2004 10:30 pm    Post subject: Reply with quote

On a project I'm working on right now...

-O2 works fine
-O1 works fine
-O0 TLB exception
no -O at all (is this same as -O0? I can't remember) TLB exception
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Sep 20, 2004 10:46 pm    Post subject: Reply with quote

From gcc's manual:

Code:

       -O1    Optimize.   Optimizing  compilation takes somewhat more time, and a lot more memory for a large func­
              tion.

              Without `-O', the compiler's goal is to reduce the cost of compilation and to make debugging  produce
              the  expected results.  Statements are independent: if you stop the program with a breakpoint between
              statements, you can then assign a new value to any variable or change the program counter to any oth­
              er statement in the function and get exactly the results you would expect from the source code.

              Without  `-O',  only  variables declared register are allocated in registers.  The resulting compiled
              code is a little worse than produced by PCC without `-O'.

              With `-O', the compiler tries to reduce code size and execution time.

              When you specify `-O', the two options `-fthread-jumps' and `-fdefer-pop' are turned on.  On machines
              that  have delay slots, the `-fdelayed-branch' option is turned on.  For those machines that can sup­
              port debugging even without a frame pointer, the `-fomit-frame-pointer' option is turned on.  On some
              machines other flags may also be turned on.

       -O2    Optimize  even  more.   Nearly all supported optimizations that do not involve a space-speed tradeoff
              are performed.  Loop unrolling and function inlining are not done, for example.  As compared  to  -O,
              this option increases both compilation time and the performance of the generated code.

       -O3    Optimize  yet more. This turns on everything -O2 does, along with also turning on -finline-functions.

       -O0    Do not optimize.


So, please, can you try compiling your software without stripping and without -O, and, run it until it fails, then, ee-objdump -dx on your elf file to read at the specified location by ps2link what is the faulty instruction. Bug me here or on IRC if you can't understand the asm code ;)
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
tjd



Joined: 27 May 2004
Posts: 23
Location: Austin, TX

PostPosted: Wed Sep 22, 2004 5:03 am    Post subject: Reply with quote

On the IOP, with GCC3.2.2 I've encountered [recently-- like last week] a set of strangeness related to -O2. When I backed off to -O0, the code worked as expected. -O1 didn't work either. Basically, the address of variables seemed to get lost. I'm suspecting a register allocation problem (or perhaps somebody in the call chain is not saving/restoring registers). When I have a chance, I'll dig into it more...

I know, I know. Don't use GCC3.2.2 for the IO. It's broken... it'll never work... it'll eat your children... Well, up until now, it's been pretty good and does support C++ which gives me good compatibility with the EE. Sigh.
Back to top
View user's profile Send private message Visit poster's website
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Wed Sep 22, 2004 5:10 am    Post subject: Reply with quote

Can you provide some code snipplet?
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group