??? 05/24/12 22:24 Read: times |
#187516 - More keil optimizer interesting tidbits Responding to: ???'s previous message |
Helping out the compiler is not always the best, as it turns out.
/* Uses 0x19 bytes of code */ static void put_id1(U8 id_indx, U8 id) { U8 idata id_char; id_char = 'A' + id_indx; printf("<ID_%bc>%02bu</ID_%bc>n", id_char, id, id_char); } /* Uses 0x15 bytes of code */ static void put_id2(U8 id_indx, U8 id) { printf("<ID_%bc>%02bu</ID_%bc>n", 'A' + id_indx, id, 'A' + id_indx); } Trying to be clever and pre-compute the ASCII char doesn't help the compiler at all in this case, where in my original post, it did. The only similarities I see between that situation and this is they both involve addition. Perhaps one can generalize this behavior and say that computations using addition can be inlined without additional overhead to the overall operation. It's just a guess at this point though. |