mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
[CPU] Add constant VectorAverage.
This commit is contained in:
parent
21b8620bf5
commit
3ced6c5cf2
|
|
@ -772,6 +772,17 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPCODE_VECTOR_AVERAGE:
|
||||||
|
if (i->src1.value->IsConstant() && i->src2.value->IsConstant()) {
|
||||||
|
v->set_from(i->src1.value);
|
||||||
|
uint32_t arith_flags = i->flags >> 8;
|
||||||
|
v->VectorAverage(i->src2.value, hir::TypeName(i->flags & 0xFF),
|
||||||
|
!!(arith_flags & ARITHMETIC_UNSIGNED),
|
||||||
|
!!(arith_flags & ARITHMETIC_SATURATE));
|
||||||
|
i->Remove();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Ignored.
|
// Ignored.
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1376,6 +1376,27 @@ void Value::DotProduct4(Value* other) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<const __m128i*>(constant.v128.i8));
|
||||||
|
__m128i src2 = _mm_load_si128(
|
||||||
|
reinterpret_cast<const __m128i*>(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));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert_unhandled_case(type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Value::ByteSwap() {
|
void Value::ByteSwap() {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INT8_TYPE:
|
case INT8_TYPE:
|
||||||
|
|
|
||||||
|
|
@ -535,6 +535,8 @@ class Value {
|
||||||
void VectorSub(Value* other, TypeName type, bool is_unsigned, bool saturate);
|
void VectorSub(Value* other, TypeName type, bool is_unsigned, bool saturate);
|
||||||
void DotProduct3(Value* other);
|
void DotProduct3(Value* other);
|
||||||
void DotProduct4(Value* other);
|
void DotProduct4(Value* other);
|
||||||
|
void VectorAverage(Value* other, TypeName type, bool is_unsigned,
|
||||||
|
bool saturate);
|
||||||
void ByteSwap();
|
void ByteSwap();
|
||||||
void CountLeadingZeros(const Value* other);
|
void CountLeadingZeros(const Value* other);
|
||||||
bool Compare(Opcode opcode, Value* other);
|
bool Compare(Opcode opcode, Value* other);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue