You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an interesting 6502 assembly optimization where you put a 256-byte page aligned table in memory with each byte having the value of its index. Then you can make some pseudo-operations:
ADC X with ADC table,X
TXY with LDY table,X
etc.
These are faster and smaller than doing it with a temp byte, so if they offset the cost of the table it can be worth it. Could such a feature (probably in the form of a flag) be added to the compiler?
The text was updated successfully, but these errors were encountered:
This sounds like something worth pursuing. For example, currently there are a lot of places that have the following code pattern: PHA ... TSX ORA $101,X INX TXS which usually could be simplified to TAX ... ORA identity,X. Variable-to-register optimization could optimize more opcodes (and since these already use cost-to-benefit calculations, they won't have speed regressions). There are also several places that could use TXY/TYX right now (even if they don't use it even on 65816)
I think it would almost always lead to larger code though, so I agree that it should be a flag.
So I checked and it turned out that the identity table is actually already used in few places at the -Ob level of optimization. I'll add more uses for it, I'll add some optimizations that target it, so that things like LDA identity,X or ORA identity+n are optimized, and I'll move it to a separate flag, so that it can be used without -Ob (which is an optimization level that is a bit ridiculous, with things like loop unrolling etc., and blows up the code size too much).
There's an interesting 6502 assembly optimization where you put a 256-byte page aligned table in memory with each byte having the value of its index. Then you can make some pseudo-operations:
These are faster and smaller than doing it with a temp byte, so if they offset the cost of the table it can be worth it. Could such a feature (probably in the form of a flag) be added to the compiler?
The text was updated successfully, but these errors were encountered: