Merge pull request #1406 from Gliniak/vsvgsb
Added support for Altivec: vavgsb
This commit is contained in:
commit
ab664e38a0
|
@ -1452,17 +1452,27 @@ void Value::VectorAverage(Value* other, TypeName type, bool is_unsigned,
|
||||||
bool saturate) {
|
bool saturate) {
|
||||||
assert_true(this->type == VEC128_TYPE && other->type == VEC128_TYPE);
|
assert_true(this->type == VEC128_TYPE && other->type == VEC128_TYPE);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INT16_TYPE: {
|
case INT8_TYPE: {
|
||||||
// TODO(gibbed): is this correct?
|
alignas(16) int8_t result[16];
|
||||||
alignas(16) int8_t result[16];
|
__m128i src1 =
|
||||||
__m128i src1 =
|
_mm_load_si128(reinterpret_cast<const __m128i*>(constant.v128.i8));
|
||||||
_mm_load_si128(reinterpret_cast<const __m128i*>(constant.v128.i8));
|
__m128i src2 = _mm_load_si128(
|
||||||
__m128i src2 = _mm_load_si128(
|
reinterpret_cast<const __m128i*>(other->constant.v128.i8));
|
||||||
reinterpret_cast<const __m128i*>(other->constant.v128.i8));
|
__m128i dest = _mm_avg_epu8(src1, src2);
|
||||||
__m128i dest = _mm_avg_epu16(src1, src2);
|
_mm_store_si128(reinterpret_cast<__m128i*>(result), dest);
|
||||||
_mm_store_si128(reinterpret_cast<__m128i*>(result), dest);
|
std::memcpy(constant.v128.i8, result, sizeof(result));
|
||||||
std::memcpy(constant.v128.i8, result, sizeof(result));
|
|
||||||
} break;
|
} break;
|
||||||
|
case INT16_TYPE: {
|
||||||
|
alignas(16) int16_t result[8];
|
||||||
|
__m128i src1 =
|
||||||
|
_mm_load_si128(reinterpret_cast<const __m128i*>(constant.v128.i16));
|
||||||
|
__m128i src2 = _mm_load_si128(
|
||||||
|
reinterpret_cast<const __m128i*>(other->constant.v128.i16));
|
||||||
|
__m128i dest = _mm_avg_epu16(src1, src2);
|
||||||
|
_mm_store_si128(reinterpret_cast<__m128i*>(result), dest);
|
||||||
|
std::memcpy(constant.v128.i16, result, sizeof(result));
|
||||||
|
} break;
|
||||||
|
// There is no _mm_avg_epu32. if there is a game that uses INT32_TYPE then it should be implemented?
|
||||||
default:
|
default:
|
||||||
assert_unhandled_case(type);
|
assert_unhandled_case(type);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue