Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit a78672c

Browse files
authored
Merge pull request #133 from Honry/sync-02-andnot
[test] Integrate v128.andnot tests from WAVM
2 parents 2687b1b + ddf1a04 commit a78672c

File tree

2 files changed

+148
-7
lines changed

2 files changed

+148
-7
lines changed

test/core/simd/meta/simd_bitwise.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SimdBitWise(SIMD):
2424
(func (export "bitselect") (param $0 v128) (param $1 v128) (param $2 v128) (result v128)
2525
(v128.bitselect (local.get $0) (local.get $1) (local.get $2))
2626
)
27+
(func (export "andnot") (param $0 v128) (param $1 v128) (result v128) (v128.andnot (local.get $0) (local.get $1)))
2728
)
2829
{normal_case}"""
2930

@@ -116,7 +117,12 @@ def get_invalid_case(self):
116117
['#', 'bitselect'],
117118
["v128.bitselect", ['0', '0', '0'], [], ['i32', 'i32x4', 'i32x4']],
118119
["v128.bitselect", ['0', '0', '0'], [], ['i32x4', 'i32x4', 'i32']],
119-
["v128.bitselect", ['0', '0', '0'], [], ['i32', 'i32', 'i32']]
120+
["v128.bitselect", ['0', '0', '0'], [], ['i32', 'i32', 'i32']],
121+
122+
['#', 'andnot'],
123+
["v128.andnot", ['0', '0'], [], ['i32', 'i32x4']],
124+
["v128.andnot", ['0', '0'], [], ['i32x4', 'i32']],
125+
["v128.andnot", ['0', '0'], [], ['i32', 'i32']]
120126
]
121127

122128
lst_ipr = self.init_case_data(case_data)
@@ -168,6 +174,7 @@ def get_combination_case(self):
168174
["v128.or", ['0', '1'], [], ['i32', 'i32']],
169175
["v128.xor", ['0', '1'], [], ['i32', 'i32']],
170176
["v128.bitselect", ['0', '1', '2'], [], ['i32', 'i32', 'i32']],
177+
["v128.andnot", ['0', '1'], [], ['i32', 'i32']],
171178
]
172179
lst_ipr = self.init_case_data(case_data)
173180

@@ -223,10 +230,9 @@ def get_combination_case(self):
223230
'\n (v128.load (i32.const 1))' \
224231
'\n (v128.load (i32.const 2))' \
225232
'\n )' \
226-
'\n (v128.bitselect' \
233+
'\n (v128.andnot' \
227234
'\n (v128.load (i32.const 0))' \
228235
'\n (v128.load (i32.const 1))' \
229-
'\n (v128.load (i32.const 2))' \
230236
'\n )' \
231237
'\n )' \
232238
'\n )' \
@@ -330,6 +336,20 @@ def get_case_data(self):
330336
['0x55555555', '0xAAAAAAAA', '0x00000000', '0xFFFFFFFF']],
331337
[['0x00000000', '0xFFFFFFFF', '0x55555555', '0xAAAAAAAA']],
332338
['i32x4', 'i32x4', 'i32x4', 'i32x4']],
339+
["andnot", [['0', '-1'], ['0', '-1', '0', '-1']], [['0', '0', '-1', '0']], ['i32x4', 'i32x4', 'i32x4']],
340+
["andnot", ['0', '0'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
341+
["andnot", ['0', '-1'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
342+
["andnot", ['0', '0xFFFFFFFF'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
343+
["andnot", ['1', '1'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
344+
["andnot", ['255', '85'], ['170'], ['i32x4', 'i32x4', 'i32x4']],
345+
["andnot", ['255', '128'], ['127'], ['i32x4', 'i32x4', 'i32x4']],
346+
["andnot", ['2863311530', ['10', '128', '5', '165']], [['2863311520', '2863311402', '2863311530', '2863311370']],
347+
['i32x4', 'i32x4', 'i32x4']],
348+
["andnot", ['0xFFFFFFFF', '0x55555555'], ['0xAAAAAAAA'], ['i32x4', 'i32x4', 'i32x4']],
349+
["andnot", ['0xFFFFFFFF', '0xAAAAAAAA'], ['0x55555555'], ['i32x4', 'i32x4', 'i32x4']],
350+
["andnot", ['0xFFFFFFFF', '0x0'], ['0xFFFFFFFF'], ['i32x4', 'i32x4', 'i32x4']],
351+
["andnot", ['0x55555555', ['0x5555', '0xFFFF', '0x55FF', '0x5FFF']], ['0x55550000'],
352+
['i32x4', 'i32x4', 'i32x4']],
333353

334354
['#', 'for float special data [e.g. -nan nan -inf inf]'],
335355
["not", ['-nan'], ['5.87747e-39'], ['f32x4', 'f32x4']],
@@ -379,7 +399,18 @@ def get_case_data(self):
379399
["bitselect", ['nan', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
380400
["bitselect", ['-inf', '-inf','0xA5A5A5A5'], ['-inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
381401
["bitselect", ['-inf', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
382-
["bitselect", ['inf', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']]
402+
["bitselect", ['inf', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
403+
404+
["andnot", ['-nan', '-nan'], ['0x00000000'], ['f32x4', 'f32x4', 'i32x4']],
405+
["andnot", ['-nan', 'nan'], ['-0'], ['f32x4', 'f32x4', 'f32x4']],
406+
["andnot", ['-nan', '-inf'], ['0x00400000'], ['f32x4', 'f32x4', 'i32x4']],
407+
["andnot", ['-nan', 'inf'], ['0x80400000'], ['f32x4', 'f32x4', 'i32x4']],
408+
["andnot", ['nan', 'nan'], ['0x00000000'], ['f32x4', 'f32x4', 'f32x4']],
409+
["andnot", ['nan', '-inf'], ['0x00400000'], ['f32x4', 'f32x4', 'i32x4']],
410+
["andnot", ['nan', 'inf'], ['0x00400000'], ['f32x4', 'f32x4', 'i32x4']],
411+
["andnot", ['-inf', '-inf'], ['0x00000000'], ['f32x4', 'f32x4', 'f32x4']],
412+
["andnot", ['-inf', 'inf'], ['0x80000000'], ['f32x4', 'f32x4', 'i32x4']],
413+
["andnot", ['inf', 'inf'], ['0x00000000'], ['f32x4', 'f32x4', 'i32x4']]
383414
]
384415

385416
def gen_test_cases(self):

test/core/simd/simd_bitwise.wast

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
(func (export "bitselect") (param $0 v128) (param $1 v128) (param $2 v128) (result v128)
99
(v128.bitselect (local.get $0) (local.get $1) (local.get $2))
1010
)
11+
(func (export "andnot") (param $0 v128) (param $1 v128) (result v128) (v128.andnot (local.get $0) (local.get $1)))
1112
)
1213

1314
;; i32x4
@@ -155,6 +156,42 @@
155156
(v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555)
156157
(v128.const i32x4 0x55555555 0xAAAAAAAA 0x00000000 0xFFFFFFFF))
157158
(v128.const i32x4 0x00000000 0xFFFFFFFF 0x55555555 0xAAAAAAAA))
159+
(assert_return (invoke "andnot" (v128.const i32x4 0 0 -1 -1)
160+
(v128.const i32x4 0 -1 0 -1))
161+
(v128.const i32x4 0 0 -1 0))
162+
(assert_return (invoke "andnot" (v128.const i32x4 0 0 0 0)
163+
(v128.const i32x4 0 0 0 0))
164+
(v128.const i32x4 0 0 0 0))
165+
(assert_return (invoke "andnot" (v128.const i32x4 0 0 0 0)
166+
(v128.const i32x4 -1 -1 -1 -1))
167+
(v128.const i32x4 0 0 0 0))
168+
(assert_return (invoke "andnot" (v128.const i32x4 0 0 0 0)
169+
(v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF))
170+
(v128.const i32x4 0 0 0 0))
171+
(assert_return (invoke "andnot" (v128.const i32x4 1 1 1 1)
172+
(v128.const i32x4 1 1 1 1))
173+
(v128.const i32x4 0 0 0 0))
174+
(assert_return (invoke "andnot" (v128.const i32x4 255 255 255 255)
175+
(v128.const i32x4 85 85 85 85))
176+
(v128.const i32x4 170 170 170 170))
177+
(assert_return (invoke "andnot" (v128.const i32x4 255 255 255 255)
178+
(v128.const i32x4 128 128 128 128))
179+
(v128.const i32x4 127 127 127 127))
180+
(assert_return (invoke "andnot" (v128.const i32x4 2863311530 2863311530 2863311530 2863311530)
181+
(v128.const i32x4 10 128 5 165))
182+
(v128.const i32x4 2863311520 2863311402 2863311530 2863311370))
183+
(assert_return (invoke "andnot" (v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF)
184+
(v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555))
185+
(v128.const i32x4 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA))
186+
(assert_return (invoke "andnot" (v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF)
187+
(v128.const i32x4 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA))
188+
(v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555))
189+
(assert_return (invoke "andnot" (v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF)
190+
(v128.const i32x4 0x0 0x0 0x0 0x0))
191+
(v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF))
192+
(assert_return (invoke "andnot" (v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555)
193+
(v128.const i32x4 0x5555 0xFFFF 0x55FF 0x5FFF))
194+
(v128.const i32x4 0x55550000 0x55550000 0x55550000 0x55550000))
158195

159196
;; for float special data [e.g. -nan nan -inf inf]
160197
(assert_return (invoke "not" (v128.const f32x4 -nan -nan -nan -nan))
@@ -295,6 +332,36 @@
295332
(v128.const f32x4 inf inf inf inf)
296333
(v128.const f32x4 0xA5A5A5A5 0xA5A5A5A5 0xA5A5A5A5 0xA5A5A5A5))
297334
(v128.const f32x4 inf inf inf inf))
335+
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
336+
(v128.const f32x4 -nan -nan -nan -nan))
337+
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000))
338+
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
339+
(v128.const f32x4 nan nan nan nan))
340+
(v128.const f32x4 -0 -0 -0 -0))
341+
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
342+
(v128.const f32x4 -inf -inf -inf -inf))
343+
(v128.const i32x4 0x00400000 0x00400000 0x00400000 0x00400000))
344+
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
345+
(v128.const f32x4 inf inf inf inf))
346+
(v128.const i32x4 0x80400000 0x80400000 0x80400000 0x80400000))
347+
(assert_return (invoke "andnot" (v128.const f32x4 nan nan nan nan)
348+
(v128.const f32x4 nan nan nan nan))
349+
(v128.const f32x4 0x00000000 0x00000000 0x00000000 0x00000000))
350+
(assert_return (invoke "andnot" (v128.const f32x4 nan nan nan nan)
351+
(v128.const f32x4 -inf -inf -inf -inf))
352+
(v128.const i32x4 0x00400000 0x00400000 0x00400000 0x00400000))
353+
(assert_return (invoke "andnot" (v128.const f32x4 nan nan nan nan)
354+
(v128.const f32x4 inf inf inf inf))
355+
(v128.const i32x4 0x00400000 0x00400000 0x00400000 0x00400000))
356+
(assert_return (invoke "andnot" (v128.const f32x4 -inf -inf -inf -inf)
357+
(v128.const f32x4 -inf -inf -inf -inf))
358+
(v128.const f32x4 0x00000000 0x00000000 0x00000000 0x00000000))
359+
(assert_return (invoke "andnot" (v128.const f32x4 -inf -inf -inf -inf)
360+
(v128.const f32x4 inf inf inf inf))
361+
(v128.const i32x4 0x80000000 0x80000000 0x80000000 0x80000000))
362+
(assert_return (invoke "andnot" (v128.const f32x4 inf inf inf inf)
363+
(v128.const f32x4 inf inf inf inf))
364+
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000))
298365

299366
;; Type check
300367

@@ -316,6 +383,10 @@
316383
(assert_invalid (module (func (result v128) (v128.bitselect (i32.const 0) (v128.const i32x4 0 0 0 0) (v128.const i32x4 0 0 0 0)))) "type mismatch")
317384
(assert_invalid (module (func (result v128) (v128.bitselect (v128.const i32x4 0 0 0 0) (v128.const i32x4 0 0 0 0) (i32.const 0)))) "type mismatch")
318385
(assert_invalid (module (func (result v128) (v128.bitselect (i32.const 0) (i32.const 0) (i32.const 0)))) "type mismatch")
386+
;; andnot
387+
(assert_invalid (module (func (result v128) (v128.andnot (i32.const 0) (v128.const i32x4 0 0 0 0)))) "type mismatch")
388+
(assert_invalid (module (func (result v128) (v128.andnot (v128.const i32x4 0 0 0 0) (i32.const 0)))) "type mismatch")
389+
(assert_invalid (module (func (result v128) (v128.andnot (i32.const 0) (i32.const 0)))) "type mismatch")
319390

320391
;; Combination
321392

@@ -380,6 +451,18 @@
380451
)
381452
)
382453
)
454+
(func (export "v128.andnot-in-block")
455+
(block
456+
(drop
457+
(block (result v128)
458+
(v128.andnot
459+
(block (result v128) (v128.load (i32.const 0)))
460+
(block (result v128) (v128.load (i32.const 1)))
461+
)
462+
)
463+
)
464+
)
465+
)
383466
(func (export "nested-v128.not")
384467
(drop
385468
(v128.not
@@ -526,6 +609,32 @@
526609
)
527610
)
528611
)
612+
(func (export "nested-v128.andnot")
613+
(drop
614+
(v128.andnot
615+
(v128.andnot
616+
(v128.andnot
617+
(v128.load (i32.const 0))
618+
(v128.load (i32.const 1))
619+
)
620+
(v128.andnot
621+
(v128.load (i32.const 0))
622+
(v128.load (i32.const 1))
623+
)
624+
)
625+
(v128.andnot
626+
(v128.andnot
627+
(v128.load (i32.const 0))
628+
(v128.load (i32.const 1))
629+
)
630+
(v128.andnot
631+
(v128.load (i32.const 0))
632+
(v128.load (i32.const 1))
633+
)
634+
)
635+
)
636+
)
637+
)
529638
(func (export "as-param")
530639
(drop
531640
(v128.or
@@ -543,10 +652,9 @@
543652
(v128.load (i32.const 1))
544653
(v128.load (i32.const 2))
545654
)
546-
(v128.bitselect
655+
(v128.andnot
547656
(v128.load (i32.const 0))
548657
(v128.load (i32.const 1))
549-
(v128.load (i32.const 2))
550658
)
551659
)
552660
)
@@ -558,9 +666,11 @@
558666
(assert_return (invoke "v128.or-in-block"))
559667
(assert_return (invoke "v128.xor-in-block"))
560668
(assert_return (invoke "v128.bitselect-in-block"))
669+
(assert_return (invoke "v128.andnot-in-block"))
561670
(assert_return (invoke "nested-v128.not"))
562671
(assert_return (invoke "nested-v128.and"))
563672
(assert_return (invoke "nested-v128.or"))
564673
(assert_return (invoke "nested-v128.xor"))
565674
(assert_return (invoke "nested-v128.bitselect"))
566-
(assert_return (invoke "as-param"))
675+
(assert_return (invoke "nested-v128.andnot"))
676+
(assert_return (invoke "as-param"))

0 commit comments

Comments
 (0)