summary refs log tree commit diff
path: root/lisc/test
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-09 19:34:20 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:30 -0400
commit44329afff582b3e6a45421cf8b29e1bb98f2ed5b (patch)
tree44ecc4f2b63ca9945bff6e7ca2a45f32c6658c85 /lisc/test
parent29c5f508b9039af15f0485fb3555304f680e5f99 (diff)
downloadroux-44329afff582b3e6a45421cf8b29e1bb98f2ed5b.tar.gz
add funny little max ssa test
Diffstat (limited to 'lisc/test')
-rw-r--r--lisc/test/max.ssa25
1 files changed, 25 insertions, 0 deletions
diff --git a/lisc/test/max.ssa b/lisc/test/max.ssa
new file mode 100644
index 0000000..d5e1d4c
--- /dev/null
+++ b/lisc/test/max.ssa
@@ -0,0 +1,25 @@
+# find the maximum value
+# in a nul-terminated array
+# of unsigned bytes
+#
+# b input array
+# a output max
+
+@start
+@loop
+	%max =w phi @start -1, @new %byt, @old %max
+	%id0 =l phi @start 0,  @new %id1, @old %id1
+	%loc =l add $b, %id0
+	%byt =w loadub %loc
+	%id1 =l add 1, %id0
+	jnz %byt, @iter, @end
+@iter
+	%cmp =w csle %max, %byt
+	jnz %cmp, @new, @old
+@new
+	jmp @loop
+@old
+	jmp @loop
+@end
+	store %max, $a
+	ret