From d85bfc18941f290d698d9b65b375b9ec9fc396c9 Mon Sep 17 00:00:00 2001 From: "chss95cs@gmail.com" Date: Sat, 20 Aug 2022 14:22:05 -0700 Subject: [PATCH] Dont constant evaluate MAX with V128! Fix signed zeroes behavior for vmaxfp emulation, was causing a block in sonic to move perpetually, very slowly --- src/xenia/cpu/backend/x64/x64_sequences.cc | 4 ++-- src/xenia/cpu/compiler/passes/constant_propagation_pass.cc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index 10498f92b..d5dad5cd7 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -549,12 +549,12 @@ struct MAX_F64 : Sequence> { struct MAX_V128 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.ChangeMxcsrMode(MXCSRMode::Vmx); - + //if 0 and -0, return 0! opposite of minfp auto src1 = GetInputRegOrConstant(e, i.src1, e.xmm0); auto src2 = GetInputRegOrConstant(e, i.src2, e.xmm1); e.vmaxps(e.xmm2, src1, src2); e.vmaxps(e.xmm3, src2, src1); - e.vorps(i.dest, e.xmm2, e.xmm3); + e.vandps(i.dest, e.xmm2, e.xmm3); } }; EMITTER_OPCODE_TABLE(OPCODE_MAX, MAX_F32, MAX_F64, MAX_V128); diff --git a/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc b/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc index a4e39e78c..26f0fecb4 100644 --- a/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc +++ b/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc @@ -600,6 +600,9 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder, bool& result) { break; case OPCODE_MAX: if (i->src1.value->IsConstant() && i->src2.value->IsConstant()) { + if (should_skip_because_of_float) { + break; + } v->set_from(i->src1.value); v->Max(i->src2.value); i->Remove();