1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
|
(module
(import "fuzzing-support" "log-f32" (func $logf32 (param f32)))
(import "fuzzing-support" "log-f64" (func $logf64 (param f64)))
(func $test32 (export "test32")
(call $logf32
(f32.add
(f32.const -nan:0x7fff82)
(f32.neg
(f32.const -nan:0x7ff622)
)
)
)
(call $logf32
(f32.sub
(f32.const -nan:0x7fff82)
(f32.neg
(f32.const -nan:0x7ff622)
)
)
)
(call $logf32
(f32.div
(f32.const -nan:0x7fff82)
(f32.neg
(f32.const -nan:0x7ff622)
)
)
)
(call $logf32
(f32.min
(f32.const -nan:0x7fff82)
(f32.neg
(f32.const -nan:0x7ff622)
)
)
)
(call $logf32
(f32.max
(f32.const -nan:0x7fff82)
(f32.neg
(f32.const -nan:0x7ff622)
)
)
)
)
(func $test64 (export "test64")
(call $logf64
(f64.add
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
(call $logf64
(f64.sub
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
(call $logf64
(f64.mul
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
(call $logf64
(f64.div
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
(call $logf64
(f64.copysign
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
(call $logf64
(f64.min
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
(call $logf64
(f64.max
(f64.const -nan:0xfffffffffff82)
(f64.neg
(f64.const -nan:0xfffffffffa622)
)
)
)
)
(func $ignore (export "ignore")
;; none of these are nan inputs, so the interpreter must not change the sign
(call $logf32
(f32.div
(f32.const 0)
(f32.neg
(f32.const 0)
)
)
)
(call $logf32
(f32.div
(f32.const -0)
(f32.neg
(f32.const 0)
)
)
)
(call $logf32
(f32.div
(f32.const 0)
(f32.neg
(f32.const -0)
)
)
)
(call $logf32
(f32.div
(f32.const -0)
(f32.neg
(f32.const -0)
)
)
)
)
)
(module
(import "fuzzing-support" "log-i32" (func $log (param i32)))
(func $signed-comparison-to-unsigned
(call $log
(i32.eq ;; should be false
(i32.shr_s ;; 0x0000006b after the sign-extend
(i32.shl
(i32.const -25749) ;; 0xffff9b6b
(i32.const 24)
)
(i32.const 24)
)
(i32.const -149) ;; 0xffffff6b - high bits are set, but not sign bit
)
)
;; the same, with mixed high bits. mixed bits mean the two sides can never be
;; equal, so the eq is always false
(call $log
(i32.eq
(i32.shr_s
(i32.shl
(i32.const -25749)
(i32.const 24)
)
(i32.const 24)
)
(i32.const 0xffffeb)
)
)
;; the same, with !=, so the result is always true
(call $log
(i32.ne
(i32.shr_s
(i32.shl
(i32.const -25749)
(i32.const 24)
)
(i32.const 24)
)
(i32.const 0xffffeb)
)
)
)
(func $foo (export "foo") (param $0 i32)
;; 8 - 0x80000000 < 0
;;
;; is not the same as
;;
;; 8 < 0x80000000
;;
;; because of overflow. the former is true, the latter is false
(call $log
(i32.le_s
(i32.sub
(i32.const 8)
(block $label$1 (result i32) ;; the block prevents us from optimizing this
;; which would avoid the issue. a global or a
;; call would do the same, all would make the
;; value only visible at runtime
(i32.const 0x80000000)
)
)
(i32.const 0)
)
)
;; for comparison, without the block.
(call $log
(i32.le_s
(i32.sub
(i32.const 8)
(i32.const 0x80000000)
)
(i32.const 0)
)
)
;; for comparison, what X - Y < 0 => X < Y would lead to, which has a
;; different value
(call $log
(i32.le_s
(i32.const 8)
(i32.const 0x80000000)
)
)
)
(func $shift (param $0 i32)
(call $log
;; x << 24 >> 24 << 30 >> 24 - the extra shifts make it invalid to do the
;; optimization of not repeating a sign-extend. That is, this would be valid
;; if the 30 were replaced by a 24.
(i32.shr_s
(i32.shl
(i32.shr_s
(i32.shl
(local.get $0)
(i32.const 24)
)
(i32.const 24)
)
(i32.const 30)
)
(i32.const 24)
)
)
)
(func $do-shift (export "do-shift")
(call $shift
(i32.const 65419)
)
)
;; similar, but with the value compared to having the sign bit set but no
;; upper bits
(func $compare-maybe-signed-eq (param $0 i32) (result i32)
(i32.eq
(i32.shr_s
(i32.shl
(local.get $0)
(i32.const 24)
)
(i32.const 24)
)
(i32.const 128)
)
)
(func $call-compare-maybe-signed-eq (export "call-compare-maybe-signed-eq") (result i32)
(call $compare-maybe-signed-eq
(i32.const 128)
)
)
;; the same with !=
(func $compare-maybe-signed-ne (param $0 i32) (result i32)
(i32.ne
(i32.shr_s
(i32.shl
(local.get $0)
(i32.const 24)
)
(i32.const 24)
)
(i32.const 128)
)
)
(func $call-compare-maybe-signed-ne (export "call-compare-maybe-signed-ne") (result i32)
(call $compare-maybe-signed-ne
(i32.const 128)
)
)
)
|