Code profiler providing info how long takes execution of each part of your program. In result, if something does spent most of CPU time, it means that it's your program bottleneck. If you speed up this part of code, your program will increase speed very much.tryphon wrote:In fact, no. Until recently, I didn't even know these tools exist, and since, I don't really see how they help.
C optimizations
Moderator: Stef
Re: C optimizations
Re: C optimizations
what about the array vs pointer optimization ?
and limit loop using several test per loop, not only one ?
more on http://www.linuxjournal.com/article/2622?page=0,1
is it valuable on this gcc version ?
and limit loop using several test per loop, not only one ?
more on http://www.linuxjournal.com/article/2622?page=0,1
is it valuable on this gcc version ?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: C optimizations
Of course, that kind of optimization always help the compiler
Re: C optimizations
Some things I noticed reading disassemblies.
When I do a multiplication :
I get :
Why is that ? shouldn't be the 2 lowest bits cleared adter a lsl ? (not that it really slows down things)
When I do a multiplication :
Code: Select all
pos = tile*4;
Code: Select all
move.w 10(a6), d2 ; pos = tile*4;
lsl.l #2, d2
and.l #0xFFFC, d2
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: C optimizations
I guess it does that because you are using a 16 bit type ? still it shows the poor code generation of GCC here, if you really use 16 bit type it should then use "lsl.w" instruction instead (and so the and operation become useless)
-
- Very interested
- Posts: 50
- Joined: Tue Dec 24, 2013 1:00 am
Re: C optimizations
You'll want to be careful with this idea. Modern CPUs are very different from something like the 68k, and what works well on one might not work well on another.cero wrote:OP: Port the cpu-heavy parts to your host machine and profile there, with the superior tools available.