http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimize my code...




 > Hmm, your compiler should optimize the code for you... 
 
Don't trust a compiler for optimizing ... your compiler doesn't know what is
heavily called, and what is important. For instance, you may want to use
as much as registers as you can for the inner loop of an image filter, and the
compiler won't because it does not know that this inner loop is THE important
one .. and maybe it will lock eax to save Y !! So unless the compiler does
profiling <- -> compiling  loops, you can beat him .. (on some specific things)
 
I think i'd rather trust my compiler than make unreadable code. However, if you know
how to help your compiler optimize, all the better. Although the register keyword may help
on a homemade compiler that compiles your code word for word, most modern compilers
make the variables into register variables if they are used alot anyway. And, in fact, i have
seen compilers optimize pretty well (At least until the point where only asm can help for
speed).