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