aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/fo3.zc
blob: b2ac93e96bcde4dbd9faf805039d725ec2017aa1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace;
include rt;

// 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() { rt.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() {
	rt.put_n((int)poly(2000)); sp();
	rt.put_n((int)poly3(2000)); sp();
	put_f(folded()); sp();
	put_f(subself(0.0 / 0.0)); sp();
	rt.put_n(zfalse()); sp();
	put_f(addtwo(1.25)); sp();
	rt.put_n(below(1.0, 2.0)); sp();
	rt.put_n(below(2.0, 2.0)); sp();
	rt.put_n(below(0.0 / 0.0, 1.0));
	rt.put_c(10);
	return 0;
}