aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/fib.c
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2023-06-24 22:49:48 +0200
committer lemon<lsof@mailbox.org>2023-06-24 22:49:48 +0200
commit2c9174841434e39ba0a9675946efe25be0d8a168 (patch)
tree150bde400e89f5a502d2d89b1a92cde0a854a622 /test/fib.c
parent02d7b9d8c67b12f2e105ee56399a1fc633bcbe0f (diff)
backend: don't mixup float and int temps
copy propagation only happens when dataclasses match, register allocator ignores hints if hint register class and instruction class differ, also add mov between int and float regs in amd64/emit
Diffstat (limited to 'test/fib.c')
-rw-r--r--test/fib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/fib.c b/test/fib.c
index eadce03..5fe430a 100644
--- a/test/fib.c
+++ b/test/fib.c
@@ -13,6 +13,16 @@ unsigned fibr(unsigned x) {
return fibr(x-1) + fibr(x-2);
}
+double fibf(unsigned x) {
+ double r = 0., q = 1.;
+ while (x-- > 1) {
+ double s = r + q;
+ r = q;
+ q = s;
+ }
+ return q;
+}
+
int atoi(const char *);
int printf(const char *, ...);
@@ -20,6 +30,7 @@ int main(int argc, char **argv) {
unsigned n = argv[1] ? atoi(argv[1]) : 10;
printf("fib(%u) = %u\n", n, fib(n));
printf("fibr(%u) = %u\n", n, fibr(n));
+ printf("fibf(%u) = %g\n", n, fibf(n));
}
/* vim:set ts=3 sw=3 expandtab: */