From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-12-09 18:42:56
Hi!
On Tue, Dec 09, 2003 at 06:05:53PM +0100, Spiro Trikaliotis wrote:
> On the other hand: As the special case carlos mentioned would be able to
> be found and removed by a peephole optimizer, I ask myself if this
> really is too much complexity?
You seem to underestimate the complexity of even a simple change like this. In
the example
ldx foobar+1
tax
sta charvar
removing the "tax" instruction will change the contents of X. What if X is
used later? What if the code reads:
ldx foobar+1
tax
sta charvar
... ; twenty more instructions not using X
lda var,x
Is an optimizer that has to look forward an unknown number of instructions
still a peep hole optimizer? It may be possible to ignore this problem, hoping
that the compiler doesn't generate this sort of code. But if a lot of the
optimizer code is built on this assumption, what if parts of the code
generator are changed later? And what about inline assembly?
Please note that I didn't say it is not possible to do this sort of code
modification. But it is definitely more complex than just replacing a pattern
of three instructions by one of two.
> Is this sequence only occurring while using shifts, or are there other
> circumstances that may lead to these?
As far as I can say it is only occuring for right shifts by 8 bits, and in
addition to that, the left operand must be a global variable. The pattern for
locals looks different as well as the pattern for anything else as the left
operand.
Regards
Uz
--
Ullrich von Bassewitz uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-12-09 18:43:08 CET