summary refs log tree commit diff
path: root/lisc/test
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-22 16:42:46 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-30 13:20:42 -0400
commit6e0c39404795ced4a9b3e6c54e2b361e87d6ee35 (patch)
treec65bc0f2c7fcb15dc0c4b8e2cceac9456c821ca6 /lisc/test
parent97db80da3133cd8d46038e3811a04d340d19ce98 (diff)
downloadroux-6e0c39404795ced4a9b3e6c54e2b361e87d6ee35.tar.gz
add a test for addressing mode optimization
Diffstat (limited to 'lisc/test')
-rw-r--r--lisc/test/sum.ssa21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisc/test/sum.ssa b/lisc/test/sum.ssa
new file mode 100644
index 0000000..2541e31
--- /dev/null
+++ b/lisc/test/sum.ssa
@@ -0,0 +1,21 @@
+# Simple test for addressing modes.
+
+function w $sum(l %arr, w %num) {
+@start
+	%n0 =w sub %num, 1
+@loop
+	%n1 =w phi @start %n0, @loop1 %n2
+	%s0 =w phi @start 0, @loop1 %s1
+	%c =w csle %n1, 0
+	jnz %c, @end, @loop1
+@loop1
+	%idx0 =l extuw %num
+	%idx1 =l mul 4, %idx0
+	%idx2 =l add %idx1, %arr
+	%w =w loadw %idx2
+	%s1 =w add %w, %s0
+	%n2 =w sub %n1, 1
+	jmp @loop
+@end
+	ret %s0
+}