aboutsummaryrefslogtreecommitdiff
path: root/test/prime.ssa
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2016-03-27 15:00:45 -0400
committerQuentin Carbonneaux <[email protected]>2016-03-27 15:00:45 -0400
commit36635660b40573f6a0c19d50dfdd9277589030de (patch)
treea1b4463f7260462c314bd8d7cb35b3d199143f33 /test/prime.ssa
parentaad52241c88ad5327a8488c66dc906c8393c9c92 (diff)
extract tests out of src
Diffstat (limited to 'test/prime.ssa')
-rw-r--r--test/prime.ssa32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/prime.ssa b/test/prime.ssa
new file mode 100644
index 0000000..12d0273
--- /dev/null
+++ b/test/prime.ssa
@@ -0,0 +1,32 @@
+# find the 10,001st prime
+# store it in a
+
+function $test() {
+@start
+@loop
+ %n =w phi @start 5, @tloop %n, @yes %n1
+ %p =w phi @start 13, @tloop %p1, @yes %p1
+ %p1 =w add %p, 2
+@tloop
+ %t =w phi @loop 3, @next %t1
+ %r =w rem %p, %t
+ jnz %r, @next, @loop
+@next
+ %t1 =w add 2, %t
+ %tsq =w mul %t1, %t1
+ %c0 =w csgtw %tsq, %p
+ jnz %c0, @yes, @tloop
+@yes
+ %n1 =w add 1, %n
+ %c1 =w ceqw 10001, %n1
+ jnz %c1, @end, @loop
+@end
+ storew %p, $a
+ ret
+}
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 104743); }
+# <<<