Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (40 sloc) 2.17 KB
libcpu - TODO
These are very old notes; they were intented for the old static recompiler
that emitted C source code. I'll leave some of the notes here for now,
but remember to understand them in the right context!
/* Optimizations
* int flags vs. char flags -> no change
* global vs. local variables (i386/x86_64) -> local is 6-8% faster
* x86_64 vs. i386 -> x86_64 1% faster!
* don't emulate V -> 9% faster
* optimize ABSX/ABSY for case that can't wrap around -> no change
* remove wrap around from INDY (inaccurate) -> no change
* N detection using <0 vs. >>7 -> no change (same assembly)
* llvm -O9 -> 70% slower
* -fomit-frame-pointer -> 7% slower
* -O0 -> 55% slower
* -Os vs. -O3 -> no change
* JSR/RTS 16 bit optimizations on little endian -> 6% faster
* bool instead of int flags -> no change (typedef'd to int)
* declared temp8/temp16 locally to help register alloc -> no change
* dedicated switch table for every RTS -> 6% slower!!
* don't calculate Z and N; instead cache results -> 20% slower
* have a special RTS table for every RTS - with a fallback to the generic one:
running program must make statistics, which RTS returns to where how often
and pass it to the recompiler, which adds a special RTS switch table at the
RTS location, but with "if ... else if..." (based on frequency) instead of switch.
XXX the static C recompiler had this, and performance was great. libcpu
does not have this yet.
* at every RTS, add code to lookup the 6502 return address in a table and
compare it with __builtin_return(0). if the same, use RTS -- save on JSR side
* never index RAM directly, instead use a macro that handles the wraparound
* 6502 code uses optimizations like LDA #0; BEQ l1 -> the next location might
not be code any more - but we delete it from the binary
XXX LLVM will understand that one of the targets is unreachable, so that's
fine; but yes, deleting the original code is a problem.
* cbmbasic: omit "?"on INPUT if input is stdin (line apple1basic)
* GEOS: recognize i_* calls and skip inline data; enables OPTIMIZE_EXECUTABLE
* ...
Jump to Line
Something went wrong with that request. Please try again.