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; }