Re: [cc65] Optimizing C code

Date view Thread view Subject view

From: Shawn Jefferson (sjefferson_at_sd62.bc.ca)
Date: 2003-09-04 23:09:50


>What's the problem?
>
>  if (creg != BAKCOL(bmp->mode)) {              // not background color?
>      bmp->dat[index] = (bmp->dat[index] & ~plot4cmask[bit]) |
>                        (creg+1) << plot4cshift[bit];
>  } else {
>      bmp->dat[index] = (bmp->dat[index] & ~plot4cmask[bit]);
>  }
>
>This will generate larger code, but on each code path, the array is addressed
>two times as before. I'm not sure if this will actually generate faster code,
>you will have to look at the assembly to find out.

I wrote a little benchmarking program to tell me which way is faster.  I did as many plots as I could in two minutes and then divided by 2.

Your way (above) gave me 338 pixels per minute, and leaving it the old way gave 345.  Both with the other optimizations mentioned previously (removing the not ~mask, using unsigned ints, etc...) and of course -Osir as well.

Thanks for all the help and information so far!

¯
Shawn


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-09-04 23:12:48 CEST