Page 2 of 2
Re: C optimizations
Posted: Fri Jan 29, 2016 2:23 pm
by r57shell
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.
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.
Re: C optimizations
Posted: Sat Jan 30, 2016 10:09 pm
by KanedaFr
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 ?
Re: C optimizations
Posted: Sun Jan 31, 2016 12:54 pm
by Stef
Of course, that kind of optimization always help the compiler

Re: C optimizations
Posted: Thu Feb 25, 2016 1:15 pm
by tryphon
Some things I noticed reading disassemblies.
When I do a multiplication :
I get :
Code: Select all
move.w 10(a6), d2 ; pos = tile*4;
lsl.l #2, d2
and.l #0xFFFC, d2
Why is that ? shouldn't be the 2 lowest bits cleared adter a lsl ? (not that it really slows down things)
Re: C optimizations
Posted: Fri Feb 26, 2016 1:00 pm
by Stef
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)
Re: C optimizations
Posted: Wed Mar 02, 2016 9:13 pm
by ehaliewicz
cero wrote:OP: Port the cpu-heavy parts to your host machine and profile there, with the superior tools available.
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.