Re: [cc65] Optimization for size

From: Andrew J. Kroll <forge1dr.ea.ms>
Date: 2006-04-05 14:23:26
> 
> On Wednesday 05 April 2006 13:10, Ullrich von Bassewitz wrote:
> > On Wed, Apr 05, 2006 at 09:46:25AM +0200, Groepaz wrote:
> > > i'm just wondering because i did a simelar thing before (using
> > > handcrafted rules though) and the result wasnt quite THAT good.
> >
> > There are two differences: The rule set is automatically generated,
> > therefore it is really large (about 13000 rules/patterns). And, it is
> > generated from one set of sources, so the rule set will be optimal for this
> > set of sources. Both differences mean that the rule set by itself is not
> > really generic. But the general approach is. You can always run a program
> > over your .s files that detects common patterns, generate a set of
> > replacement rules, and then replace common code sequences by a set of
> > subroutines.
> >
> > However, the approach is beyond what would normally be done by a compiler,
> > because to generate an optimal set of patterns, you will have to look at
> > all assembly files for a complete project, not just at one module (as the
> > compiler does).
> 
> yes ofcourse :)
> 
> as for the compiler, what about adding a little bit of support for undocs to 
> the codegenerator (or rather, the internal optimizer) ? might also safe some 
> memory (and gain speed) in some cases, and it can be done very generic :)
> 

Part of the reason the optimizer may have worked so well for me may be infact 
because I did run it over more than one program. Granted your not going to
ALWAYS see the same paterns, however cc65 proves to alwyas have some specfic
reoccuring code. I don't exactly remember what it was, but I saw something
on the order of 500+ times the occurance of loading something to a and x and
then a jsr to something that pushed it on the soft stack. Compressing that 
sequence alone saves 4 bytes per instance as long as it occurs two or
more times.

It's all the more reason I should run more code thru the pattern locater, 
and see what pops out for a comparason. For the most part, I'm very certain
that the mid-sized rules in the library are quite commonly repeated.
One of the most common one you'll see is LDA #$00 and then a store, and always
seems to go to the same location because of the softstack...


Yours,
-- 
Andrew J. Kroll
Software and Hardware Engineer and Consultant
Grafixoft http://dr.ea.ms/HW/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Apr 5 14:23:37 2006

This archive was generated by hypermail 2.1.8 : 2006-04-05 14:23:39 CEST