|
189 | 189 | (v128.const f64x2 -0x1.000002p+0 -0x1.000002p+0)
|
190 | 190 | (v128.const f64x2 -0x1.00000204p+0 -0x1.00000204p+0))
|
191 | 191 | (v128.const i64x2 -1 -1))
|
| 192 | + |
| 193 | +;; Test that the non-deterministic choice of fusing and then rounding or |
| 194 | +;; rounding multiple times in `relaxed_madd` is consistent throughout a |
| 195 | +;; program's execution. |
| 196 | +;; |
| 197 | +;; This property is impossible to test exhaustively, so this is just a simple |
| 198 | +;; smoke test for when the operands to a `relaxed_madd` are known statically |
| 199 | +;; versus when they are dynamically supplied. This should, at least, catch |
| 200 | +;; illegal constant-folding and -propagation by the compiler that leads to |
| 201 | +;; inconsistent rounding behavior at compile time versus at run time. |
| 202 | +;; |
| 203 | +;; FLT_MAX == 0x1.fffffep+127 |
| 204 | +;; FLT_MAX * 2 - FLT_MAX == |
| 205 | +;; FLT_MAX (if fma) |
| 206 | +;; 0 (if no fma) |
| 207 | +;; from https://www.vinc17.net/software/fma-tests.c |
| 208 | +(module |
| 209 | + (func (export "test-consistent-nondeterminism") (param v128 v128 v128) (result v128) |
| 210 | + (f32x4.eq |
| 211 | + (f32x4.relaxed_madd (v128.const f32x4 0x1.fffffep+127 0x1.fffffep+127 0x1.fffffep+127 0x1.fffffep+127 ) |
| 212 | + (v128.const f32x4 2.0 2.0 2.0 2.0) |
| 213 | + (v128.const f32x4 -0x1.fffffep+127 -0x1.fffffep+127 -0x1.fffffep+127 -0x1.fffffep+127)) |
| 214 | + (f32x4.relaxed_madd (local.get 0) |
| 215 | + (local.get 1) |
| 216 | + (local.get 2)) |
| 217 | + ) |
| 218 | + ) |
| 219 | +) |
| 220 | +(assert_return (invoke "test-consistent-nondeterminism" |
| 221 | + (v128.const f32x4 0x1.fffffep+127 0x1.fffffep+127 0x1.fffffep+127 0x1.fffffep+127 ) |
| 222 | + (v128.const f32x4 2.0 2.0 2.0 2.0) |
| 223 | + (v128.const f32x4 -0x1.fffffep+127 -0x1.fffffep+127 -0x1.fffffep+127 -0x1.fffffep+127)) |
| 224 | + (v128.const i32x4 -1 -1 -1 -1)) |
0 commit comments