From 53eb95d33c30ad95ed178f1c70ec1119597b6816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gli=C5=84ski?= Date: Thu, 18 Jul 2019 21:22:42 +0200 Subject: [PATCH] Added support for Altivec: vavgsb Also little size adjustments for vavgsh --- src/xenia/cpu/hir/value.cc | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/xenia/cpu/hir/value.cc b/src/xenia/cpu/hir/value.cc index ed79d65a2..5f60bb03e 100644 --- a/src/xenia/cpu/hir/value.cc +++ b/src/xenia/cpu/hir/value.cc @@ -1380,17 +1380,27 @@ void Value::VectorAverage(Value* other, TypeName type, bool is_unsigned, bool saturate) { assert_true(this->type == VEC128_TYPE && other->type == VEC128_TYPE); switch (type) { - case INT16_TYPE: { - // TODO(gibbed): is this correct? - alignas(16) int8_t result[16]; - __m128i src1 = - _mm_load_si128(reinterpret_cast(constant.v128.i8)); - __m128i src2 = _mm_load_si128( - reinterpret_cast(other->constant.v128.i8)); - __m128i dest = _mm_avg_epu16(src1, src2); - _mm_store_si128(reinterpret_cast<__m128i*>(result), dest); - std::memcpy(constant.v128.i8, result, sizeof(result)); + case INT8_TYPE: { + alignas(16) int8_t result[16]; + __m128i src1 = + _mm_load_si128(reinterpret_cast(constant.v128.i8)); + __m128i src2 = _mm_load_si128( + reinterpret_cast(other->constant.v128.i8)); + __m128i dest = _mm_avg_epu8(src1, src2); + _mm_store_si128(reinterpret_cast<__m128i*>(result), dest); + std::memcpy(constant.v128.i8, result, sizeof(result)); } break; + case INT16_TYPE: { + alignas(16) int16_t result[8]; + __m128i src1 = + _mm_load_si128(reinterpret_cast(constant.v128.i16)); + __m128i src2 = _mm_load_si128( + reinterpret_cast(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: assert_unhandled_case(type); break;