diff --git a/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc b/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc index 29ce3e02d..0663cb613 100644 --- a/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc +++ b/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc @@ -153,6 +153,14 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder) { i->Remove(); } break; + case OPCODE_CONVERT: + if (i->src1.value->IsConstant()) { + TypeName target_type = v->type; + v->set_from(i->src1.value); + v->Convert(target_type, ROUND_TO_NEAREST); + i->Remove(); + } + break; case OPCODE_ZERO_EXTEND: if (i->src1.value->IsConstant()) { TypeName target_type = v->type; @@ -195,10 +203,29 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder) { !(protect & kMemoryProtectWrite) && (protect & kMemoryProtectRead)) { // Memory is readonly - can just return the value. + auto host_addr = memory->TranslateVirtual(address); switch (v->type) { + case INT8_TYPE: + v->set_constant(xe::load(host_addr)); + i->Remove(); + break; + case INT16_TYPE: + v->set_constant(xe::load(host_addr)); + i->Remove(); + break; case INT32_TYPE: - v->set_constant( - xe::load(memory->TranslateVirtual(address))); + v->set_constant(xe::load(host_addr)); + i->Remove(); + break; + case INT64_TYPE: + v->set_constant(xe::load(host_addr)); + i->Remove(); + break; + case VEC128_TYPE: + vec128_t val; + val.low = xe::load(host_addr); + val.high = xe::load(host_addr + 8); + v->set_constant(val); i->Remove(); break; default: