-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cranelift-interpreter: Implement a bunch of SIMD arithmetic ops (#5991)
* cranelift: Add function name to tests * cranelift: Move simd-ineg tests to separate file * cranelift: Move `avg_round` tests to separate file * cranelift: Move SIMD `fmin`/`fmax` tests to separate files * cranelift-interpreter: Implement a bunch of SIMD arithmetic ops Most of these are quite easy to adapt to be polymorphic * cranelift: Move shift tests from `simd-arithmetic.clif` into shift files
- Loading branch information
Showing
11 changed files
with
277 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
cranelift/filetests/filetests/runtests/simd-avg-round-small.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
; the interpreter does not currently support SIMD `avg_round`. | ||
test run | ||
target aarch64 | ||
; x86_64 and s390x do not currently support 64-bit vectors, or | ||
; `avg_round` on `i64x2` values. | ||
; x86_64 also does not currently support `avg_round.i32x4`. | ||
|
||
function %average_rounding_i8x8(i8x8, i8x8) -> i8x8 { | ||
block0(v0: i8x8, v1: i8x8): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i8x8([0 0 0 1 42 19 -1 0xff], [0 1 2 4 42 18 -1 0]) == [0 1 1 3 42 19 -1 0x80] | ||
|
||
function %average_rounding_i16x4(i16x4, i16x4) -> i16x4 { | ||
block0(v0: i16x4, v1: i16x4): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i16x4([0 0 0 1], [0 1 2 4]) == [0 1 1 3] | ||
; run: %average_rounding_i16x4([42 19 -1 0xffff], [42 18 -1 0]) == [42 19 -1 0x8000] | ||
|
||
function %average_rounding_i32x2(i32x2, i32x2) -> i32x2 { | ||
block0(v0: i32x2, v1: i32x2): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i32x2([0 0], [0 1]) == [0 1] | ||
; run: %average_rounding_i32x2([0 1], [2 4]) == [1 3] | ||
; run: %average_rounding_i32x2([42 19], [42 18]) == [42 19] | ||
; run: %average_rounding_i32x2([-1 0xffffffff], [-1 0]) == [-1 0x80000000] | ||
; run: %average_rounding_i32x2([0xffffffff 0xfffffffd], [10 0xffffffff]) == [0x80000005 0xfffffffe] | ||
|
||
function %average_rounding_i32x4(i32x4, i32x4) -> i32x4 { | ||
block0(v0: i32x4, v1: i32x4): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i32x4([0 0 0 0xffffffff], [0 1 2 0]) == [0 1 1 0x80000000] | ||
; run: %average_rounding_i32x4([1 42 19 -1], [4 42 18 -1]) == [3 42 19 -1] | ||
|
||
function %average_rounding_i64x2(i64x2, i64x2) -> i64x2 { | ||
block0(v0: i64x2, v1: i64x2): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i64x2([0 0], [0 1]) == [0 1] | ||
; run: %average_rounding_i64x2([0 1], [2 4]) == [1 3] | ||
; run: %average_rounding_i64x2([42 19], [42 18]) == [42 19] | ||
; run: %average_rounding_i64x2([-1 0xffffffffffffffff], [-1 0]) == [-1 0x8000000000000000] | ||
; run: %average_rounding_i64x2([0xffffffffffffffff 0xfffffffffffffffd], [10 0xffffffffffffffff]) == [0x8000000000000005 0xfffffffffffffffe] | ||
|
51 changes: 10 additions & 41 deletions
51
cranelift/filetests/filetests/runtests/simd-avg-round.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,20 @@ | ||
; the interpreter does not currently support SIMD `avg_round`. | ||
test run | ||
target aarch64 | ||
; x86_64 and s390x do not currently support 64-bit vectors, or | ||
; `avg_round` on `i64x2` values. | ||
; x86_64 also does not currently support `avg_round.i32x4`. | ||
target s390x | ||
set enable_simd | ||
target x86_64 | ||
target x86_64 skylake | ||
|
||
function %average_rounding_i8x8(i8x8, i8x8) -> i8x8 { | ||
block0(v0: i8x8, v1: i8x8): | ||
function %average_rounding_i8x16(i8x16, i8x16) -> i8x16 { | ||
block0(v0: i8x16, v1: i8x16): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i8x8([0 0 0 1 42 19 -1 0xff], [0 1 2 4 42 18 -1 0]) == [0 1 1 3 42 19 -1 0x80] | ||
; run: %average_rounding_i8x16([0 0 0 1 42 19 -1 0xff 5 0 0 0 1 42 19 -1], [0 1 2 4 42 18 -1 0 10 0 1 2 4 42 18 -1]) == [0 1 1 3 42 19 -1 0x80 8 0 1 1 3 42 19 -1] | ||
|
||
function %average_rounding_i16x4(i16x4, i16x4) -> i16x4 { | ||
block0(v0: i16x4, v1: i16x4): | ||
function %average_rounding_i16x8(i16x8, i16x8) -> i16x8 { | ||
block0(v0: i16x8, v1: i16x8): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i16x4([0 0 0 1], [0 1 2 4]) == [0 1 1 3] | ||
; run: %average_rounding_i16x4([42 19 -1 0xffff], [42 18 -1 0]) == [42 19 -1 0x8000] | ||
|
||
function %average_rounding_i32x2(i32x2, i32x2) -> i32x2 { | ||
block0(v0: i32x2, v1: i32x2): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i32x2([0 0], [0 1]) == [0 1] | ||
; run: %average_rounding_i32x2([0 1], [2 4]) == [1 3] | ||
; run: %average_rounding_i32x2([42 19], [42 18]) == [42 19] | ||
; run: %average_rounding_i32x2([-1 0xffffffff], [-1 0]) == [-1 0x80000000] | ||
; run: %average_rounding_i32x2([0xffffffff 0xfffffffd], [10 0xffffffff]) == [0x80000005 0xfffffffe] | ||
|
||
function %average_rounding_i32x4(i32x4, i32x4) -> i32x4 { | ||
block0(v0: i32x4, v1: i32x4): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i32x4([0 0 0 0xffffffff], [0 1 2 0]) == [0 1 1 0x80000000] | ||
; run: %average_rounding_i32x4([1 42 19 -1], [4 42 18 -1]) == [3 42 19 -1] | ||
|
||
function %average_rounding_i64x2(i64x2, i64x2) -> i64x2 { | ||
block0(v0: i64x2, v1: i64x2): | ||
v2 = avg_round v0, v1 | ||
return v2 | ||
} | ||
; run: %average_rounding_i64x2([0 0], [0 1]) == [0 1] | ||
; run: %average_rounding_i64x2([0 1], [2 4]) == [1 3] | ||
; run: %average_rounding_i64x2([42 19], [42 18]) == [42 19] | ||
; run: %average_rounding_i64x2([-1 0xffffffffffffffff], [-1 0]) == [-1 0x8000000000000000] | ||
; run: %average_rounding_i64x2([0xffffffffffffffff 0xfffffffffffffffd], [10 0xffffffffffffffff]) == [0x8000000000000005 0xfffffffffffffffe] | ||
; run: %average_rounding_i16x8([0 0 0 1 42 19 -1 0xffff], [0 1 2 4 42 18 -1 0]) == [0 1 1 3 42 19 -1 0x8000] |
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
cranelift/filetests/filetests/runtests/simd-fmax-fmin.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
test run | ||
target aarch64 | ||
target s390x | ||
set enable_simd | ||
target x86_64 | ||
target x86_64 skylake | ||
|
||
function %fmax_f64x2(f64x2, f64x2) -> f64x2 { | ||
block0(v0: f64x2, v1: f64x2): | ||
v2 = fmax v0, v1 | ||
return v2 | ||
} | ||
; This operation exhibits non-deterministic behaviour for some input NaN values; | ||
; refer to the simd-fmax-fmin-nondeterministic*.clif files for the respective tests. | ||
; run: %fmax_f64x2([-0x0.0 -0x1.0], [+0x0.0 0x1.0]) == [+0x0.0 0x1.0] | ||
; run: %fmax_f64x2([-NaN NaN], [0x0.0 0x100.0]) == [-NaN NaN] | ||
; run: %fmax_f64x2([NaN 0.0], [0.0 0.0]) == [NaN 0.0] | ||
; run: %fmax_f64x2([-NaN 0.0], [0x1.0 0.0]) == [-NaN 0.0] | ||
|
||
function %fmin_f64x2(f64x2, f64x2) -> f64x2 { | ||
block0(v0: f64x2, v1: f64x2): | ||
v2 = fmin v0, v1 | ||
return v2 | ||
} | ||
; This operation exhibits non-deterministic behaviour for some input NaN values; | ||
; refer to the simd-fmax-fmin-nondeterministic*.clif files for the respective tests. | ||
; run: %fmin_f64x2([-0x0.0 -0x1.0], [+0x0.0 0x1.0]) == [-0x0.0 -0x1.0] | ||
; run: %fmin_f64x2([-NaN 0.0], [0x1.0 0.0]) == [-NaN 0.0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test run | ||
target aarch64 | ||
target s390x | ||
set enable_simd | ||
target x86_64 | ||
target x86_64 skylake | ||
|
||
function %ineg_i32x4(i32x4) -> i32x4 { | ||
block0(v0: i32x4): | ||
v1 = ineg v0 | ||
return v1 | ||
} | ||
; run: %ineg_i32x4([1 1 1 1]) == [-1 -1 -1 -1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.