diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-16 14:42:27 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:31 -0400 |
commit | c334258427b3bcd08c32f83b6919a61fdb83322c (patch) | |
tree | 9d18f5086f54f6508f12ca952c332fac25467024 /lisc/test | |
parent | 6dc9646f5eced9065d4f6cfdf3979db5cfb48b56 (diff) | |
download | roux-c334258427b3bcd08c32f83b6919a61fdb83322c.tar.gz |
compactify collatz test
Diffstat (limited to 'lisc/test')
-rw-r--r-- | lisc/test/collatz.ssa | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/lisc/test/collatz.ssa b/lisc/test/collatz.ssa index 8918c76..b763827 100644 --- a/lisc/test/collatz.ssa +++ b/lisc/test/collatz.ssa @@ -6,61 +6,48 @@ # todo, insert sign extensions @start - %mem =l alloc4 4000 - + %mem =l alloc4 4000 @loop - %n =w phi @start 1, @newm %n9, @oldm %n9 - %cmax =w phi @start 0, @newm %c, @oldm %cmax - - %fin =w cslt %n, 1000 + %n =w phi @start 1, @newm %n9, @oldm %n9 + %cmax =w phi @start 0, @newm %c, @oldm %cmax + %fin =w cslt %n, 1000 jnz %fin, @cloop, @end - @cloop - %n0 =w phi @loop %n, @odd %n2, @even %n3 - %c0 =w phi @loop 0, @odd %c1, @even %c1 - - %is1 =w ceq %n0, 1 + %n0 =w phi @loop %n, @odd %n2, @even %n3 + %c0 =w phi @loop 0, @odd %c1, @even %c1 + %is1 =w ceq %n0, 1 jnz %is1, @endcl, @iter0 - @iter0 - %ism =w cslt %n0, %n - jnz %ism, @getmemo, @iter1 # we have it in the table - + %ism =w cslt %n0, %n + jnz %ism, @getmemo, @iter1 @iter1 - %c1 =w add %c0, 1 - %p =w and %n0, 1 + %c1 =w add %c0, 1 + %p =w and %n0, 1 jnz %p, @odd, @even - @odd - %n1 =w mul 3, %n0 # compute %n2 = 3 * %n0 + 1 - %n2 =w add %n1, 1 + %n1 =w mul 3, %n0 + %n2 =w add %n1, 1 jmp @cloop - @even - %n3 =w div %n0, 2 # %n3 = %n0 / 2 + %n3 =w div %n0, 2 jmp @cloop - -@getmemo +@getmemo # get the count for n0 in mem %idx0 =l mul %n0, 4 %loc0 =l add %idx0, %mem - %cn0 =w load %loc0 - %c2 =w add %c0, %cn0 - -@endcl - %c =w phi @getmemo %c2, @cloop %c0 - - %idx1 =l mul %n, 4 - %loc1 =l add %idx1, %mem - storew %c, %loc1 # memorize the result - %n9 =w add 1, %n - %big =w csle %cmax, %c + %cn0 =w load %loc0 + %c2 =w add %c0, %cn0 +@endcl # store the count for n in mem + %c =w phi @getmemo %c2, @cloop %c0 + %idx1 =l mul %n, 4 + %loc1 =l add %idx1, %mem + storew %c, %loc1 + %n9 =w add 1, %n + %big =w csle %cmax, %c jnz %big, @newm, @oldm - @newm jmp @loop @oldm jmp @loop - @end storew %cmax, $a ret |