Hi! On Mon, Oct 19, 2009 at 07:40:54PM +0200, Thomas Giesel wrote: > Accidently I found the piece of code below. Is it possible to optimize > the ldx L000F out? Technically: yes. But as with all optimization steps I have to consider if the sequence in question is used often enough to warrant code in the compiler to replace it. Which in this special case is probably not true. But I've checked similar sequences and I think I can come up with something that improves them all. If you notice other sequences that are apparently stupid and could be improved easily, please let me know. I will not be able to fix all of them, but I will at least give it a thought. > I don't know if the compiler knows that the value > isn't used later. The backend does register tracking, even for a few zeropage locations. It does not only know if a register is used later, it does also track contents along branches. If you look at the code generated for the following sequence: ----------------------------------------------------------------------------- int b = 3; char c = 0; int main (void) { char a; if (b != 3) { if (c == 0) { c = 3; } else if (c != 3) { b = 3; } } a = 3; return 0; } ----------------------------------------------------------------------------- you will notice that for the final assignment, the accumulator is not reloaded, because the compiler knows that it contains the correct value for each possible execution path. Regards Uz -- Ullrich von Bassewitz uz@musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Tue Oct 20 10:05:14 2009
This archive was generated by hypermail 2.1.8 : 2009-10-20 10:05:16 CEST