interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / omc / tests / float / vcmp.om

143 lines · 1688 bytes Raw Blame History
1note float compares of names that live in v registers read both operands from their own twins (#861,
2note finding 1: the f32 FCMP word carried Rm bit 0, so a second operand in an even twin read the next
3note one). Each case leaves a different value in the twin after the second operand: a stale read flips
4note the answer. Expected answers follow from IEEE-754 order, never from this compiler.
5fn c_self to int
6r = ulong 0
7x = f32 2.0
8y = sub mul x x x
9if lt y y
10r = ulong 1
11end
12ret int r
13end
14
15fn c_xy to int
16r = ulong 0
17x = f32 2.0
18y = sub mul x x x
19if lt x y
20r = ulong 1
21end
22ret int r
23end
24
25fn c_ne to int
26r = ulong 0
27x = f32 2.0
28y = sub mul x x x
29if ne y y
30r = ulong 1
31end
32ret int r
33end
34
35fn c_value to int
36r = ulong 0
37x = f32 2.0
38y = sub mul x x x
39w = lt y y
40if w
41r = ulong 1
42end
43ret int r
44end
45
46fn c_while to int
47r = ulong 0
48x = f32 2.0
49y = sub mul x x x
50while lt y y
51r = add r 1
52y = add y 10.0
53if gt r 3
54ret 1
55end
56end
57ret int r
58end
59
60fn c_two to int
61r = ulong 0
62x = f32 2.0
63y = mul x x
64q = mul y y
65if lt y y
66r = ulong 1
67end
68ret int r
69end
70
71fn q32 a f32 b ulong to ulong
72if eq a f32 1.0
73ret b
74end
75ret 0
76end
77
78fn c_true to int
79r = ulong 0
80x = f32 2.0
81y = sub mul x x x
82z = f32 1.0
83if not le y y
84ret 1
85end
86if not eq y y
87ret 1
88end
89if not lt z y
90ret 1
91end
92if not gt y z
93ret 1
94end
95if ne q32 z 1 1
96ret 1
97end
98ret int r
99end
100
101fn c_d64 to int
102r = ulong 0
103x = f64 2.0
104y = sub mul x x x
105if lt y y
106r = ulong 1
107end
108if lt x y
109r = ulong 1
110end
111if ne y y
112r = ulong 1
113end
114ret int r
115end
116
117fn main to int
118if ne c_self 0
119ret 1
120end
121if ne c_xy 0
122ret 2
123end
124if ne c_ne 0
125ret 3
126end
127if ne c_value 0
128ret 4
129end
130if ne c_while 0
131ret 5
132end
133if ne c_two 0
134ret 6
135end
136if ne c_true 0
137ret 7
138end
139if ne c_d64 0
140ret 8
141end
142ret 0
143end