Implement SaddSat and SsubSat for the interpreter
Implemented `SaddSat` and `SsubSat` to add and subtract signed vector values, saturating at the type boundaries rather than overflowing. Changed the parser to allow signed `i8` immediates in vectors as part of this work; fixes #3276. Copyright (c) 2021, Arm Limited.
This commit is contained in:
19
cranelift/filetests/filetests/runtests/simd-ssubsat.clif
Normal file
19
cranelift/filetests/filetests/runtests/simd-ssubsat.clif
Normal file
@@ -0,0 +1,19 @@
|
||||
test interpret
|
||||
test run
|
||||
target aarch64
|
||||
set enable_simd
|
||||
target x86_64
|
||||
|
||||
function %ssubsat_i8x16(i8x16, i8x16) -> i8x16 {
|
||||
block0(v0: i8x16, v1: i8x16):
|
||||
v2 = ssub_sat v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %ssubsat_i8x16([1 100 100 100 100 100 100 100 -100 -100 -100 -100 -100 -100 -100 -100], [1 -100 -100 -100 -100 -100 -100 -100 100 100 100 100 100 100 100 100]) == [0 127 127 127 127 127 127 127 -128 -128 -128 -128 -128 -128 -128 -128]
|
||||
|
||||
function %ssubsat_i16x8(i16x8, i16x8) -> i16x8 {
|
||||
block0(v0: i16x8, v1: i16x8):
|
||||
v2 = ssub_sat v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %ssubsat_i16x8([1 -32000 -32000 -32000 32000 32000 32000 32000], [1 1000 1000 1000 -1000 -1000 -1000 -1000]) == [0 -32768 -32768 -32768 32767 32767 32767 32767]
|
||||
Reference in New Issue
Block a user