Loading fold.fs +17 −0 Original line number Diff line number Diff line Loading @@ -202,3 +202,20 @@ optimizes fpick ' opt-modf optimizes umod \ does not optimize MIN-N UMOD; add another optimizer if you want that. : opt-/modf ( xt -- ) lits# 1 = if lits> dup 0> over pow2? and if dup 1- ]] dup literal and [[ ctz ]] swap literal arshift [[ drop exit then >lits then fold2-2 ; ' opt-/modf optimizes /modf : opt-u/mod ( xt -- ) lits# 1 = if lits> dup pow2? if dup 1- ]] dup literal and [[ ctz ]] swap literal rshift [[ drop exit then >lits then fold2-2 ; ' opt-u/mod optimizes u/mod peeprules.vmg +3 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ super33 = noop flit super34 = lit+ @ super35 = f@ f* super36 = f@ f+ super37 = lit and super38 = lit arshift super39 = dup lit and swap \ compare-and-branch; comment them out if we take up work on gforth-native again cb1 = 0< ?branch Loading test/gforth.fs +9 −0 Original line number Diff line number Diff line Loading @@ -409,3 +409,12 @@ t{ 2 5 -7 */mod -> -4 -2 }t t{ -2 5 -7 */mod -> -3 1 }t t{ -2 15 -1 u*/mod -> -16 14 }t \ optimization of division words t{ :noname -21 4 /f ; execute -> -6 }t t{ :noname -21 4 modf ; execute -> 3 }t t{ :noname -21 4 /modf ; execute -> 3 -6 }t t{ :noname 25 4 u/ ; execute -> 6 }t t{ :noname 25 4 umod ; execute -> 1 }t t{ :noname 25 4 u/mod ; execute -> 1 6 }t Loading
fold.fs +17 −0 Original line number Diff line number Diff line Loading @@ -202,3 +202,20 @@ optimizes fpick ' opt-modf optimizes umod \ does not optimize MIN-N UMOD; add another optimizer if you want that. : opt-/modf ( xt -- ) lits# 1 = if lits> dup 0> over pow2? and if dup 1- ]] dup literal and [[ ctz ]] swap literal arshift [[ drop exit then >lits then fold2-2 ; ' opt-/modf optimizes /modf : opt-u/mod ( xt -- ) lits# 1 = if lits> dup pow2? if dup 1- ]] dup literal and [[ ctz ]] swap literal rshift [[ drop exit then >lits then fold2-2 ; ' opt-u/mod optimizes u/mod
peeprules.vmg +3 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ super33 = noop flit super34 = lit+ @ super35 = f@ f* super36 = f@ f+ super37 = lit and super38 = lit arshift super39 = dup lit and swap \ compare-and-branch; comment them out if we take up work on gforth-native again cb1 = 0< ?branch Loading
test/gforth.fs +9 −0 Original line number Diff line number Diff line Loading @@ -409,3 +409,12 @@ t{ 2 5 -7 */mod -> -4 -2 }t t{ -2 5 -7 */mod -> -3 1 }t t{ -2 15 -1 u*/mod -> -16 14 }t \ optimization of division words t{ :noname -21 4 /f ; execute -> -6 }t t{ :noname -21 4 modf ; execute -> 3 }t t{ :noname -21 4 /modf ; execute -> 3 -6 }t t{ :noname 25 4 u/ ; execute -> 6 }t t{ :noname 25 4 umod ; execute -> 1 }t t{ :noname 25 4 u/mod ; execute -> 1 6 }t