Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions test/core/simd/meta/simd_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SimdBitWise(SIMD):
(func (export "bitselect") (param $0 v128) (param $1 v128) (param $2 v128) (result v128)
(v128.bitselect (local.get $0) (local.get $1) (local.get $2))
)
(func (export "andnot") (param $0 v128) (param $1 v128) (result v128) (v128.andnot (local.get $0) (local.get $1)))
)
{normal_case}"""

Expand Down Expand Up @@ -116,7 +117,12 @@ def get_invalid_case(self):
['#', 'bitselect'],
["v128.bitselect", ['0', '0', '0'], [], ['i32', 'i32x4', 'i32x4']],
["v128.bitselect", ['0', '0', '0'], [], ['i32x4', 'i32x4', 'i32']],
["v128.bitselect", ['0', '0', '0'], [], ['i32', 'i32', 'i32']]
["v128.bitselect", ['0', '0', '0'], [], ['i32', 'i32', 'i32']],

['#', 'andnot'],
["v128.andnot", ['0', '0'], [], ['i32', 'i32x4']],
["v128.andnot", ['0', '0'], [], ['i32x4', 'i32']],
["v128.andnot", ['0', '0'], [], ['i32', 'i32']]
]

lst_ipr = self.init_case_data(case_data)
Expand Down Expand Up @@ -168,6 +174,7 @@ def get_combination_case(self):
["v128.or", ['0', '1'], [], ['i32', 'i32']],
["v128.xor", ['0', '1'], [], ['i32', 'i32']],
["v128.bitselect", ['0', '1', '2'], [], ['i32', 'i32', 'i32']],
["v128.andnot", ['0', '1'], [], ['i32', 'i32']],
]
lst_ipr = self.init_case_data(case_data)

Expand Down Expand Up @@ -223,10 +230,9 @@ def get_combination_case(self):
'\n (v128.load (i32.const 1))' \
'\n (v128.load (i32.const 2))' \
'\n )' \
'\n (v128.bitselect' \
'\n (v128.andnot' \
'\n (v128.load (i32.const 0))' \
'\n (v128.load (i32.const 1))' \
'\n (v128.load (i32.const 2))' \
'\n )' \
'\n )' \
'\n )' \
Expand Down Expand Up @@ -330,6 +336,20 @@ def get_case_data(self):
['0x55555555', '0xAAAAAAAA', '0x00000000', '0xFFFFFFFF']],
[['0x00000000', '0xFFFFFFFF', '0x55555555', '0xAAAAAAAA']],
['i32x4', 'i32x4', 'i32x4', 'i32x4']],
["andnot", [['0', '-1'], ['0', '-1', '0', '-1']], [['0', '0', '-1', '0']], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0', '0'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0', '-1'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0', '0xFFFFFFFF'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['1', '1'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['255', '85'], ['170'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['255', '128'], ['127'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['2863311530', ['10', '128', '5', '165']], [['2863311520', '2863311402', '2863311530', '2863311370']],
['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0xFFFFFFFF', '0x55555555'], ['0xAAAAAAAA'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0xFFFFFFFF', '0xAAAAAAAA'], ['0x55555555'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0xFFFFFFFF', '0x0'], ['0xFFFFFFFF'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0x55555555', ['0x5555', '0xFFFF', '0x55FF', '0x5FFF']], ['0x55550000'],
['i32x4', 'i32x4', 'i32x4']],

['#', 'for float special data [e.g. -nan nan -inf inf]'],
["not", ['-nan'], ['5.87747e-39'], ['f32x4', 'f32x4']],
Expand Down Expand Up @@ -379,7 +399,18 @@ def get_case_data(self):
["bitselect", ['nan', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
["bitselect", ['-inf', '-inf','0xA5A5A5A5'], ['-inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
["bitselect", ['-inf', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],
["bitselect", ['inf', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']]
["bitselect", ['inf', 'inf','0xA5A5A5A5'], ['inf'], ['f32x4', 'f32x4', 'f32x4', 'f32x4']],

["andnot", ['-nan', '-nan'], ['0x00000000'], ['f32x4', 'f32x4', 'i32x4']],
["andnot", ['-nan', 'nan'], ['-0'], ['f32x4', 'f32x4', 'f32x4']],
["andnot", ['-nan', '-inf'], ['0x00400000'], ['f32x4', 'f32x4', 'i32x4']],
["andnot", ['-nan', 'inf'], ['0x80400000'], ['f32x4', 'f32x4', 'i32x4']],
["andnot", ['nan', 'nan'], ['0x00000000'], ['f32x4', 'f32x4', 'f32x4']],
["andnot", ['nan', '-inf'], ['0x00400000'], ['f32x4', 'f32x4', 'i32x4']],
["andnot", ['nan', 'inf'], ['0x00400000'], ['f32x4', 'f32x4', 'i32x4']],
["andnot", ['-inf', '-inf'], ['0x00000000'], ['f32x4', 'f32x4', 'f32x4']],
["andnot", ['-inf', 'inf'], ['0x80000000'], ['f32x4', 'f32x4', 'i32x4']],
["andnot", ['inf', 'inf'], ['0x00000000'], ['f32x4', 'f32x4', 'i32x4']]
]

def gen_test_cases(self):
Expand Down
116 changes: 113 additions & 3 deletions test/core/simd/simd_bitwise.wast
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
(func (export "bitselect") (param $0 v128) (param $1 v128) (param $2 v128) (result v128)
(v128.bitselect (local.get $0) (local.get $1) (local.get $2))
)
(func (export "andnot") (param $0 v128) (param $1 v128) (result v128) (v128.andnot (local.get $0) (local.get $1)))
)

;; i32x4
Expand Down Expand Up @@ -155,6 +156,42 @@
(v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555)
(v128.const i32x4 0x55555555 0xAAAAAAAA 0x00000000 0xFFFFFFFF))
(v128.const i32x4 0x00000000 0xFFFFFFFF 0x55555555 0xAAAAAAAA))
(assert_return (invoke "andnot" (v128.const i32x4 0 0 -1 -1)
(v128.const i32x4 0 -1 0 -1))
(v128.const i32x4 0 0 -1 0))
(assert_return (invoke "andnot" (v128.const i32x4 0 0 0 0)
(v128.const i32x4 0 0 0 0))
(v128.const i32x4 0 0 0 0))
(assert_return (invoke "andnot" (v128.const i32x4 0 0 0 0)
(v128.const i32x4 -1 -1 -1 -1))
(v128.const i32x4 0 0 0 0))
(assert_return (invoke "andnot" (v128.const i32x4 0 0 0 0)
(v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF))
(v128.const i32x4 0 0 0 0))
(assert_return (invoke "andnot" (v128.const i32x4 1 1 1 1)
(v128.const i32x4 1 1 1 1))
(v128.const i32x4 0 0 0 0))
(assert_return (invoke "andnot" (v128.const i32x4 255 255 255 255)
(v128.const i32x4 85 85 85 85))
(v128.const i32x4 170 170 170 170))
(assert_return (invoke "andnot" (v128.const i32x4 255 255 255 255)
(v128.const i32x4 128 128 128 128))
(v128.const i32x4 127 127 127 127))
(assert_return (invoke "andnot" (v128.const i32x4 2863311530 2863311530 2863311530 2863311530)
(v128.const i32x4 10 128 5 165))
(v128.const i32x4 2863311520 2863311402 2863311530 2863311370))
(assert_return (invoke "andnot" (v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF)
(v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555))
(v128.const i32x4 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA))
(assert_return (invoke "andnot" (v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF)
(v128.const i32x4 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA))
(v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555))
(assert_return (invoke "andnot" (v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF)
(v128.const i32x4 0x0 0x0 0x0 0x0))
(v128.const i32x4 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF))
(assert_return (invoke "andnot" (v128.const i32x4 0x55555555 0x55555555 0x55555555 0x55555555)
(v128.const i32x4 0x5555 0xFFFF 0x55FF 0x5FFF))
(v128.const i32x4 0x55550000 0x55550000 0x55550000 0x55550000))

;; for float special data [e.g. -nan nan -inf inf]
(assert_return (invoke "not" (v128.const f32x4 -nan -nan -nan -nan))
Expand Down Expand Up @@ -295,6 +332,36 @@
(v128.const f32x4 inf inf inf inf)
(v128.const f32x4 0xA5A5A5A5 0xA5A5A5A5 0xA5A5A5A5 0xA5A5A5A5))
(v128.const f32x4 inf inf inf inf))
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
(v128.const f32x4 -nan -nan -nan -nan))
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000))
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
(v128.const f32x4 nan nan nan nan))
(v128.const f32x4 -0 -0 -0 -0))
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
(v128.const f32x4 -inf -inf -inf -inf))
(v128.const i32x4 0x00400000 0x00400000 0x00400000 0x00400000))
(assert_return (invoke "andnot" (v128.const f32x4 -nan -nan -nan -nan)
(v128.const f32x4 inf inf inf inf))
(v128.const i32x4 0x80400000 0x80400000 0x80400000 0x80400000))
(assert_return (invoke "andnot" (v128.const f32x4 nan nan nan nan)
(v128.const f32x4 nan nan nan nan))
(v128.const f32x4 0x00000000 0x00000000 0x00000000 0x00000000))
(assert_return (invoke "andnot" (v128.const f32x4 nan nan nan nan)
(v128.const f32x4 -inf -inf -inf -inf))
(v128.const i32x4 0x00400000 0x00400000 0x00400000 0x00400000))
(assert_return (invoke "andnot" (v128.const f32x4 nan nan nan nan)
(v128.const f32x4 inf inf inf inf))
(v128.const i32x4 0x00400000 0x00400000 0x00400000 0x00400000))
(assert_return (invoke "andnot" (v128.const f32x4 -inf -inf -inf -inf)
(v128.const f32x4 -inf -inf -inf -inf))
(v128.const f32x4 0x00000000 0x00000000 0x00000000 0x00000000))
(assert_return (invoke "andnot" (v128.const f32x4 -inf -inf -inf -inf)
(v128.const f32x4 inf inf inf inf))
(v128.const i32x4 0x80000000 0x80000000 0x80000000 0x80000000))
(assert_return (invoke "andnot" (v128.const f32x4 inf inf inf inf)
(v128.const f32x4 inf inf inf inf))
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000))

;; Type check

Expand All @@ -316,6 +383,10 @@
(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")
(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")
(assert_invalid (module (func (result v128) (v128.bitselect (i32.const 0) (i32.const 0) (i32.const 0)))) "type mismatch")
;; andnot
(assert_invalid (module (func (result v128) (v128.andnot (i32.const 0) (v128.const i32x4 0 0 0 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (v128.andnot (v128.const i32x4 0 0 0 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (v128.andnot (i32.const 0) (i32.const 0)))) "type mismatch")

;; Combination

Expand Down Expand Up @@ -380,6 +451,18 @@
)
)
)
(func (export "v128.andnot-in-block")
(block
(drop
(block (result v128)
(v128.andnot
(block (result v128) (v128.load (i32.const 0)))
(block (result v128) (v128.load (i32.const 1)))
)
)
)
)
)
(func (export "nested-v128.not")
(drop
(v128.not
Expand Down Expand Up @@ -526,6 +609,32 @@
)
)
)
(func (export "nested-v128.andnot")
(drop
(v128.andnot
(v128.andnot
(v128.andnot
(v128.load (i32.const 0))
(v128.load (i32.const 1))
)
(v128.andnot
(v128.load (i32.const 0))
(v128.load (i32.const 1))
)
)
(v128.andnot
(v128.andnot
(v128.load (i32.const 0))
(v128.load (i32.const 1))
)
(v128.andnot
(v128.load (i32.const 0))
(v128.load (i32.const 1))
)
)
)
)
)
(func (export "as-param")
(drop
(v128.or
Expand All @@ -543,10 +652,9 @@
(v128.load (i32.const 1))
(v128.load (i32.const 2))
)
(v128.bitselect
(v128.andnot
(v128.load (i32.const 0))
(v128.load (i32.const 1))
(v128.load (i32.const 2))
)
)
)
Expand All @@ -558,9 +666,11 @@
(assert_return (invoke "v128.or-in-block"))
(assert_return (invoke "v128.xor-in-block"))
(assert_return (invoke "v128.bitselect-in-block"))
(assert_return (invoke "v128.andnot-in-block"))
(assert_return (invoke "nested-v128.not"))
(assert_return (invoke "nested-v128.and"))
(assert_return (invoke "nested-v128.or"))
(assert_return (invoke "nested-v128.xor"))
(assert_return (invoke "nested-v128.bitselect"))
(assert_return (invoke "as-param"))
(assert_return (invoke "nested-v128.andnot"))
(assert_return (invoke "as-param"))