Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/omc/tests/float/fma.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / omc / tests / float / fma.om` 124 lines ยท 2288 bytes Raw Blame History 1 note fma: Wolfram rational oracle and ARM FPMulAdd semantics, see evidence/SEED-0/fma-exact-literals. 2 note In particular, rounding the product before adding returns zero instead of -2^-46 / -2^-104. 3 global cnt ulong 1 4 global vals f64 1 5 fn tick v f64 to f64 6 put cnt 0 add get cnt 0 1 7 ret v 8 end 9 fn fused a f64 b f64 c f64 to f64 10 ret fma a b c 11 end 12 fn fused32 a f32 b f32 c f32 to f32 13 ret fma a b c 14 end 15 fn check64 to int 16 a = bitcast f64 ulong `4607182418800017409` 17 b = bitcast f64 ulong `4607182418800017406` 18 r = fma a b -1.0f64 19 if ne bitcast ulong r `13362180094408261632` 20 ret 1 21 end 22 if ne bitcast ulong add mul a b -1.0f64 0 23 ret 2 24 end 25 if ne bitcast ulong fused a b -1.0f64 `13362180094408261632` 26 ret 3 27 end 28 m = bitcast f64 ulong `9218868437227405311` 29 if ne bitcast ulong fma m 2.0f64 neg m `9218868437227405311` 30 ret 4 31 end 32 s = bitcast f64 ulong 1 33 if ne bitcast ulong fma s 0.5f64 s 2 34 ret 5 35 end 36 ret 0 37 end 38 fn check32 to int 39 a = bitcast f32 uint `1065353217` 40 b = bitcast f32 uint `1065353214` 41 r = fma a b -1.0f32 42 if ne bitcast uint r `2826960896` 43 ret 6 44 end 45 if ne bitcast uint add mul a b -1.0f32 0 46 ret 7 47 end 48 if ne bitcast uint fused32 a b -1.0f32 `2826960896` 49 ret 8 50 end 51 m = bitcast f32 uint `2139095039` 52 if ne bitcast uint fma m 2.0f32 neg m `2139095039` 53 ret 9 54 end 55 s = bitcast f32 uint 1 56 if ne bitcast uint fma s 0.5f32 s 2 57 ret 10 58 end 59 ret 0 60 end 61 fn special to int 62 if ne bitcast ulong fma -0.0f64 2.0f64 -0.0f64 `9223372036854775808` 63 ret 11 64 end 65 if ne bitcast uint fma -0.0f32 2.0f32 0.0f32 0 66 ret 12 67 end 68 inf = div 1.0f64 0.0f64 69 if ne fma inf 2.0f64 0.0f64 inf 70 ret 13 71 end 72 n = fma 0.0f64 inf 1.0f64 73 if eq n n 74 ret 14 75 end 76 q = bitcast f64 ulong `9221120237041090626` 77 n = fma q 2.0f64 1.0f64 78 if eq n n 79 ret 15 80 end 81 s = bitcast f64 ulong `9218868437227405313` 82 n = fma 1.0f64 s 0.0f64 83 if eq n n 84 ret 16 85 end 86 if eq and bitcast ulong n `2251799813685248` 0 87 ret 17 88 end 89 n = fma 1.0f64 2.0f64 q 90 if eq n n 91 ret 18 92 end 93 ret 0 94 end 95 fn main to int 96 r = check64 97 if ne r 0 98 ret r 99 end 100 r = check32 101 if ne r 0 102 ret r 103 end 104 r = special 105 if ne r 0 106 ret r 107 end 108 put vals 0 fma tick 2.0f64 tick 3.0f64 tick 7.0f64 109 if ne get cnt 0 3 110 ret 19 111 end 112 if ne get vals 0 13.0f64 113 ret 20 114 end 115 v = fma 2.0f64 fma 1.0f64 2.0f64 1.0f64 7.0f64 116 v = fma v 2.0f64 -1.0f64 117 if ne v 25.0f64 118 ret 21 119 end 120 if ne fma fma 1.0f32 2.0f32 3.0f32 4.0f32 fma 1.0f32 2.0f32 3.0f32 25.0f32 121 ret 22 122 end 123 ret 0 124 end