14480RE: The Rhinestone Compiler Passes 22 Dhrystones/Sec
- Oct 6, 2013
Its been fun watching all this progress Bill. Keep up the great work!
I haven't downloaded your compiler for a while but you might want to
remind the list about what that's about.
---In firstname.lastname@example.org, <email@example.com> wrote:By dint of much hard work and low cunning I have gotten an overall 60% improvement in the dhrystone benchmark score up to 22.5 from the original score of just under 14.The biggest improvements relate to support routines rather than straightline code.I had already tweaked the multiply routine to exit more quickly for small multipliers. Today I changed the part of the compiler that emits instructions to recognize when it was working with a small constant operand and code the operation as a series of shifts and adds. For example:;Int_3_Loc = 5 * Int_1_Locld2 R13,'O',sp,(84) [loads the local variable into Reg 13]cpy2 R15,R13 [so R15=variable*1]shl2I R13,1 [R13=variable*2]shl2I R13,1 [R13=variable*4]alu2 R15,R15,R13,add,adc [now R15=variable*5]There's a penalty of code size, of course, this is a good 20 bytes bigger than the original. Realistically, you wouldn't want it to do this for constants bigger than maybe 7 - with a constant of 100 it's almost 60 bytes bigger. Execution is much much quicker though because you avoid six 16 bit shifts, a bunch of loop control stuff, and the call/return overhead. probably 200 instructions saved for very small numbers and 50 for larger ones. In net, this took out almost 700 instructions from the benchmark execution time because there are a bunch of constant multiplies for subscript calculation.I keep plugging away at the tiny gains from peephole optimization but that kind of thing is much more gratifying.A good case for the peephole is something like the followingshrU2I %1,8 [compiler wants to shift an int right 8 bits]<is replaced with>ghi %1 [move top byte to low and zero the top]plo %1ldi 0phi %1There are a bunch of things like that but they just don't show up that often.
- << Previous post in topic Next post in topic >>