Hello glasgow-haskell-users, i propose to do for start rather small change that will allow to make things go several times faster and in particular outperform jhc for the small "leaf" loops (i.e. loops that use only GHC primitives and don't call other functions). that include factorial, "a[]+=b[i]" loop that was discussed here several weeks ago, some shootout examples, my own arrays serialization code and so on, so on
the idea is that the following STG code f :: Int# -> Double# -> ... -> Int# (i.e. function use only unboxed values/results) f x y z = code1 in case expr1 of A -> codeA B -> codeB C -> codeC in f x_c y_c z_c D -> codeD in f x_d y_d z_d _ -> code0 in f x0 y0 z0 can be compiled to the following C/C-- code: f() { x = sp[0]; y = sp[4]; z = sp[8]; sp+=12; code1; while (expr1!=A) { if (expr1==B) then return codeB; else if (expr1==C) then {x=x_c; y=y_c; z=z_c;} else if (expr1==D) then {x=x_d; y=y_d; z=z_d;} else {x=x0; y=y0; z=z0;} code1; } return codeA; } this compilation don't require any changes in GHC memory model. all we need: 1) add for/if/while to the C-- statement types list (data CmmStmt) 2) implement recognizer for such simple STG functions (leaf unboxed procedures recognizer) 3) implement the translation itself as i said, it's should be no more than one day of work. i even think that it's one day for me and one hour for Simon Marlow :) Simon, how about this? i can even make the patches over current 6.6 sources and you will apply them at morning and we will see whether it work :) i yet never tried to rebuild the whole ghc :) -- Best regards, Bulat mailto:[EMAIL PROTECTED] _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users