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

Commit

Permalink
[test] Add more literal tests for rest ops (#155)
Browse files Browse the repository at this point in the history
This PR covers tests for some float literal introduced in
WebAssembly/spec#1069, specific for following
ops:

Bit shifts
Bitwise operations
Boolean horizontal reductions
Conversions
Integer comparisons
Store

These tests are pulled from WAVM/WAVM#236
  • Loading branch information
Honry authored and tlively committed Dec 11, 2019
1 parent 6b7ef4f commit bc0e8f5
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 21 deletions.
14 changes: 14 additions & 0 deletions test/core/simd/meta/simd_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def get_case_data(self):
["not", [['0', '-1', '0', '-1']], [['-1', '0', '-1', '0']], ['i32x4', 'i32x4']],
["not", ['0x55555555'], ['0xAAAAAAAA'], ['i32x4', 'i32x4']],
["not", ['3435973836'], ['858993459'], ['i32x4', 'i32x4']],
['not', ['01_234_567_890'], ['3060399405'], ['i32x4', 'i32x4']],
['not', ['0x0_1234_5678'], ['0xedcba987'], ['i32x4', 'i32x4']],
["and", [['0', '-1'], ['0', '-1', '0', '-1']], [['0', '0', '0', '-1']], ['i32x4', 'i32x4', 'i32x4']],
["and", ['0', '0'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
["and", ['0', '-1'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
Expand All @@ -283,6 +285,8 @@ def get_case_data(self):
["and", ['0xFFFFFFFF', '0x0'], ['0x0'], ['i32x4', 'i32x4', 'i32x4']],
["and", ['0x55555555', ['0x5555', '0xFFFF', '0x55FF', '0x5FFF']], ['0x5555'],
['i32x4', 'i32x4', 'i32x4']],
['and', ['01_234_567_890', '01_234_567_890'], ['1234567890'], ['i32x4', 'i32x4', 'i32x4']],
['and', ['0x0_1234_5678', '0x0_90AB_cdef'], ['0x10204468'], ['i32x4', 'i32x4', 'i32x4']],
["or", [['0', '0', '-1', '-1'], ['0', '-1', '0', '-1']], [['0', '-1', '-1', '-1']],
['i32x4', 'i32x4', 'i32x4']],
["or", ['0', '0'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
Expand All @@ -299,6 +303,8 @@ def get_case_data(self):
["or", ['0x55555555', ['0x5555', '0xFFFF', '0x55FF', '0x5FFF']],
[['0x55555555', '0x5555ffff', '0x555555ff', '0x55555fff']],
['i32x4', 'i32x4', 'i32x4']],
['or', ['01_234_567_890', '01_234_567_890'], ['1234567890'], ['i32x4', 'i32x4', 'i32x4']],
['or', ['0x0_1234_5678', '0x0_90AB_cdef'], ['0x92bfdfff'], ['i32x4', 'i32x4', 'i32x4']],
["xor", [['0', '0', '-1', '-1'], ['0', '-1', '0', '-1']], [['0', '-1', '-1', '0']],
['i32x4', 'i32x4', 'i32x4']],
["xor", ['0', '0'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
Expand All @@ -316,6 +322,8 @@ def get_case_data(self):
["xor", ['0x55555555', ['0x5555', '0xFFFF', '0x55FF', '0x5FFF']],
[['0x55550000', '0x5555AAAA', '0x555500AA', '0x55550AAA']],
['i32x4', 'i32x4', 'i32x4']],
['xor', ['01_234_567_890', '01_234_567_890'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
['xor', ['0x0_1234_5678', '0x0_90AB_cdef'], ['0x829f9b97'], ['i32x4', 'i32x4', 'i32x4']],
["bitselect", ['0xAAAAAAAA', '0xBBBBBBBB',
['0x00112345', '0xF00FFFFF', '0x10112021', '0xBBAABBAA']],
[['0xBBAABABA', '0xABBAAAAA', '0xABAABBBA', '0xAABBAABB']],
Expand All @@ -336,6 +344,10 @@ def get_case_data(self):
['0x55555555', '0xAAAAAAAA', '0x00000000', '0xFFFFFFFF']],
[['0x00000000', '0xFFFFFFFF', '0x55555555', '0xAAAAAAAA']],
['i32x4', 'i32x4', 'i32x4', 'i32x4']],
['bitselect', ['01_234_567_890', '03_060_399_406', '0xcdefcdef'], ['2072391874'],
['i32x4', 'i32x4', 'i32x4', 'i32x4']],
['bitselect', ['0x0_1234_5678', '0x0_90AB_cdef', '0xcdefcdef'], ['0x10244468'],
['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']],
Expand All @@ -350,6 +362,8 @@ def get_case_data(self):
["andnot", ['0xFFFFFFFF', '0x0'], ['0xFFFFFFFF'], ['i32x4', 'i32x4', 'i32x4']],
["andnot", ['0x55555555', ['0x5555', '0xFFFF', '0x55FF', '0x5FFF']], ['0x55550000'],
['i32x4', 'i32x4', 'i32x4']],
['andnot', ['01_234_567_890', '01_234_567_890'], ['0'], ['i32x4', 'i32x4', 'i32x4']],
['andnot', ['0x0_1234_5678', '0x0_90AB_cdef'], ['0x02141210'], ['i32x4', 'i32x4', 'i32x4']],

['#', 'for float special data [e.g. -nan nan -inf inf]'],
["not", ['-nan'], ['5.87747e-39'], ['f32x4', 'f32x4']],
Expand Down
22 changes: 21 additions & 1 deletion test/core/simd/meta/simd_i16x8_cmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['eq', [['65535', '0', '1', '32768'], ['65535', '0', '1', '32768']], ['-1', '0', '-1', '-1', '-1', '0', '-1', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['eq', ['0x5555', '0xAAAAAAAA'], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['eq', ['012_345', '12345'], '-1', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['eq', ['0x0_1234', '0x1234'], '-1', ['i16x8', 'i16x8', 'i16x8']])

# ne
# i16x8.ne (i16x8) (i16x8)
Expand Down Expand Up @@ -176,6 +178,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ne', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '-1', '0', '0', '0', '-1', '0', '-1'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ne', ['0x5555', '0xAAAAAAAA'], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ne', ['012_345', '12345'], '0', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['ne', ['0x0_1234', '0x1234'], '0', ['i16x8', 'i16x8', 'i16x8']])

# lt_s
# i16x8.lt_s (i16x8) (i16x8)
Expand Down Expand Up @@ -245,6 +249,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['lt_s', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '-1', '0', '0', '0', '0', '0', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['lt_s', ['0x5555', '0xAAAAAAAA'], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['lt_s', ['012_345', '12345'], '0', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['lt_s', ['0x0_1234', '0x1234'], '0', ['i16x8', 'i16x8', 'i16x8']])

# lt_u
# i16x8.lt_u (i16x8) (i16x8)
Expand Down Expand Up @@ -324,6 +330,8 @@ def get_case_data(self):
case_data.append(['lt_u', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']],
['0', '-1', '0', '0', '0', '0', '0', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['lt_u', ['0x5555', '0xAAAAAAAA'], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['lt_u', ['012_345', '12345'], '0', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['lt_u', ['0x0_1234', '0x1234'], '0', ['i16x8', 'i16x8', 'i16x8']])

# le_s
# i16x8.le_s (i16x8) (i16x8)
Expand Down Expand Up @@ -403,6 +411,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['le_s', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['-1', '-1', '-1', '-1', '-1', '0', '-1', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['le_s', ['0x5555', '0xAAAAAAAA'], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['le_s', ['012_345', '12345'], '-1', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['le_s', ['0x0_1234', '0x1234'], '-1', ['i16x8', 'i16x8', 'i16x8']])

# le_u
# i16x8.le_u (i16x8) (i16x8)
Expand Down Expand Up @@ -480,6 +490,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['le_u', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['-1', '-1', '-1', '-1', '-1', '0', '-1', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['le_u', ['0x5555', '0xAAAAAAAA'], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['le_u', ['012_345', '12345'], '-1', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['le_u', ['0x0_edcb', '-0x1234'], '-1', ['i16x8', 'i16x8', 'i16x8']])

# gt_s
# i16x8.gt_s (i16x8) (i16x8)
Expand Down Expand Up @@ -557,6 +569,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['gt_s', [['65535', '0', '1', '32768'], ['65535', '0', '1', '32768']], ['0', '0', '0', '0', '0', '-1', '0', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['gt_s', ['0x5555', '0xAAAAAAAA'], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['gt_s', ['012_345', '12345'], '0', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['gt_s', ['0x0_1234', '0x1234'], '0', ['i16x8', 'i16x8', 'i16x8']])

# gt_u
# i16x8.gt_u (i16x8) (i16x8)
Expand Down Expand Up @@ -635,6 +649,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['gt_u', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '0', '0', '0', '0', '-1', '0', '-1'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['gt_u', ['0x5555', '0xAAAAAAAA'], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['gt_u', ['012_345', '12345'], '0', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['gt_u', ['0x0_1234', '0x1234'], '0', ['i16x8', 'i16x8', 'i16x8']])

# ge_s
# i16x8.ge_s (i16x8) (i16x8)
Expand Down Expand Up @@ -712,6 +728,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ge_s', [['65535', '0', '1', '32768'], ['65535', '0', '1', '32768']], ['-1', '0', '-1', '-1', '-1', '-1', '-1', '0'], ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ge_s', ['0x5555', '0xAAAAAAAA'], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ge_s', ['012_345', '12345'], '-1', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['ge_s', ['0x0_1234', '0x1234'], '-1', ['i16x8', 'i16x8', 'i16x8']])

# ge_u
# i16x8.ge_u (i16x8) (i16x8)
Expand Down Expand Up @@ -789,6 +807,8 @@ def get_case_data(self):
['2206368128', '16776957', '2130837760', '4294901120']], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ge_u', [['65535', '0', '1', '32768'], ['-128', '0', '1', '255']], '-1', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ge_u', ['0x5555', '0xAAAAAAAA'], '0', ['i16x8', 'i32x4', 'i16x8']])
case_data.append(['ge_u', ['012_345', '12345'], '-1', ['i16x8', 'i16x8', 'i16x8']])
case_data.append(['ge_u', ['0x0_1234', '0x1234'], '-1', ['i16x8', 'i16x8', 'i16x8']])

return case_data

Expand All @@ -800,4 +820,4 @@ def gen_test_cases():

if __name__ == '__main__':
i16x8 = Simdi16x8CmpCase()
i16x8.gen_test_cases()
i16x8.gen_test_cases()
32 changes: 31 additions & 1 deletion test/core/simd/meta/simd_i32x4_cmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def get_case_data(self):
case_data.append(['eq', [['4294967295', '0', '1', '65535'], ['65535', '65535', '0', '0', '1', '0', '65535', '65535']], ['-1', '-1', '-1', '0'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['eq', ['0x55555555', '0xAAAA'], '0', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['eq', ['0_123_456_789', '123456789'], '-1', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['eq', ['0x0_1234_5678', '0x12345678'], '-1', ['i32x4', 'i32x4', 'i32x4']])

# ne
# i32x4.ne (i32x4) (i32x4)
case_data.append(['#', 'ne'])
Expand Down Expand Up @@ -169,6 +172,9 @@ def get_case_data(self):
case_data.append(['ne', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['-1', '0', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['ne', ['0xAAAAAAAA', '0x5555'], ['-1', '-1', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['ne', ['0_123_456_789', '123456789'], '0', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['ne', ['0x0_1234_5678', '0x12345678'], '0', ['i32x4', 'i32x4', 'i32x4']])

# lt_s
# i32x4.lt_s (i32x4) (i32x4)
case_data.append(['#', 'lt_s'])
Expand Down Expand Up @@ -246,6 +252,9 @@ def get_case_data(self):
case_data.append(['lt_s', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '0', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['lt_s', ['0xAAAAAAAA', '0x5555'], '-1', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['lt_s', ['0_123_456_789', '123456789'], '0', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['lt_s', ['0x0_90AB_cdef', '-0x6f543210'], '-1', ['i32x4', 'i32x4', 'i32x4']])

# lt_u
# i32x4.lt_u (i32x4) (i32x4)
case_data.append(['#', 'lt_u'])
Expand Down Expand Up @@ -320,6 +329,9 @@ def get_case_data(self):
case_data.append(['lt_u', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '0', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['lt_u', ['0xAAAAAAAA', '0x5555'], '0', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['lt_u', ['0_123_456_789', '123456789'], '0', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['lt_u', ['0x0_90AB_cdef', '-0x6f543210'], '-1', ['i32x4', 'i32x4', 'i32x4']])

# le_s
# i32x4.le_s (i32x4) (i32x4)
case_data.append(['#', 'le_s'])
Expand Down Expand Up @@ -396,6 +408,9 @@ def get_case_data(self):
case_data.append(['le_s', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '-1', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['le_s', ['0xAAAAAAAA', '0x5555'], '-1', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['le_s', ['0_123_456_789', '123456789'], '-1', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['le_s', ['0x0_1234_5678', '0x12345678'], '-1', ['i32x4', 'i32x4', 'i32x4']])

# le_u
# i32x4.le_u (i32x4) (i32x4)
case_data.append(['#', 'le_u'])
Expand Down Expand Up @@ -471,6 +486,9 @@ def get_case_data(self):
case_data.append(['le_u', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['0', '-1', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['le_u', ['0xAAAAAAAA', '0x5555'], '0', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['le_u', ['0_123_456_789', '123456789'], '-1', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['le_u', ['0x0_90AB_cdef', '0x90ABcdef'], '-1', ['i32x4', 'i32x4', 'i32x4']])

# gt_s
# i32x4.gt_s (i32x4) (i32x4)
case_data.append(['#', 'gt_s'])
Expand Down Expand Up @@ -546,6 +564,9 @@ def get_case_data(self):
case_data.append(['gt_s', [['65535', '0', '1', '32768'], ['65535', '65535', '0', '0', '1', '1', '32768', '32768']], ['-1', '0', '0', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['gt_s', ['0xAAAAAAAA', '0x5555'], '0', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['gt_s', ['0_123_456_789', '123456789'], '0', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['gt_s', ['0x0_90AB_cdef', '-0x6f543211'], '0', ['i32x4', 'i32x4', 'i32x4']])

# gt_u
# i32x4.gt_u (i32x4) (i32x4)
case_data.append(['#', 'gt_u'])
Expand Down Expand Up @@ -621,6 +642,9 @@ def get_case_data(self):
case_data.append(['gt_u', [['-128', '0', '1', '255'], ['-128', '0', '1', '255']], ['-1', '0', '0', '0'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['gt_u', ['0xAAAAAAAA', '0x5555'], '-1', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['gt_u', ['0_123_456_789', '123456789'], '0', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['gt_u', ['0x0_1234_5678', '0x12345678'], '0', ['i32x4', 'i32x4', 'i32x4']])

# ge_s
# i32x4.ge_s (i32x4) (i32x4)
case_data.append(['#', 'ge_s'])
Expand Down Expand Up @@ -696,6 +720,9 @@ def get_case_data(self):
case_data.append(['ge_s', [['65535', '0', '1', '32768'], ['65535', '65535', '0', '0', '1', '1', '32768', '32768']], ['-1', '-1', '0', '-1'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['ge_s', ['0xAAAAAAAA', '0x5555'], '0', ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['ge_s', ['0_123_456_789', '123456789'], '-1', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['ge_s', ['0x0_1234_5678', '0x12345678'], '-1', ['i32x4', 'i32x4', 'i32x4']])

# ge_u
# i32x4.ge_u (i32x4) (i32x4)
case_data.append(['#', 'ge_u'])
Expand Down Expand Up @@ -772,6 +799,9 @@ def get_case_data(self):
case_data.append(['ge_u', [['-128', '0', '1', '255'], ['65535', '65535', '0', '0', '1', '1', '32768', '32768']], ['0', '-1', '0', '0'], ['i32x4', 'i16x8', 'i32x4']])
case_data.append(['ge_u', ['0xAAAAAAAA', '0x5555'], ['-1', '-1', '-1', '-1'], ['i32x4', 'i16x8', 'i32x4']])

case_data.append(['ge_u', ['0_123_456_789', '123456789'], '-1', ['i32x4', 'i32x4', 'i32x4']])
case_data.append(['ge_u', ['0x0_1234_5678', '0x12345678'], '-1', ['i32x4', 'i32x4', 'i32x4']])

return case_data

# generate all test cases
Expand Down Expand Up @@ -802,4 +832,4 @@ def gen_test_cases():

if __name__ == '__main__':
i32x4 = Simdi32x4CmpCase()
i32x4.gen_test_cases()
i32x4.gen_test_cases()
Loading

0 comments on commit bc0e8f5

Please sign in to comment.