diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/fo3.zc | |
a
Diffstat (limited to 'tests/programs/fo3.zc')
| -rw-r--r-- | tests/programs/fo3.zc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/programs/fo3.zc b/tests/programs/fo3.zc new file mode 100644 index 0000000..593e88a --- /dev/null +++ b/tests/programs/fo3.zc @@ -0,0 +1,50 @@ +// o3 lifts float ops: the plain kernel and the o3 kernel agree, a constant +// float expression folds, x - x stays a NaN, and -0 is false inside o3. +fn put_f(x) { asm { x @ #1220 } return 0; } +fn sp() { put_c(32); return 0; } +float poly(int n) { + float s = 0.0; + float x = 1.25; + int i = 0; + while (i < n) { + s = s + x * 1.5; + x = x * 0.5 + 1.0; + i = i + 1; + } + return s; +} +o3 float poly3(int n) { + float s = 0.0; + float x = 1.25; + int i = 0; + while (i < n) { + s = s + x * 1.5; + x = x * 0.5 + 1.0; + i = i + 1; + } + return s; +} +o3 float folded() { return 1.5 + 2.5; } +o3 float subself(float x) { return x - x; } +o3 int zfalse() { + float z = 0.0 * -1.0; + int n = 0; + if (z) n = 1; + while (z) n = n + 2; + return n; +} +o3 float addtwo(float a) { return a + 2; } +o3 int below(float a, float b) { return a < b; } +fn main() { + put_n((int)poly(2000)); sp(); + put_n((int)poly3(2000)); sp(); + put_f(folded()); sp(); + put_f(subself(0.0 / 0.0)); sp(); + put_n(zfalse()); sp(); + put_f(addtwo(1.25)); sp(); + put_n(below(1.0, 2.0)); sp(); + put_n(below(2.0, 2.0)); sp(); + put_n(below(0.0 / 0.0, 1.0)); + put_c(10); + return 0; +} |
