diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 96f638802f..d60f4cd6a4 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -828,7 +828,7 @@ struct llvm_neg static_assert(llvm_value_t::is_sint || llvm_value_t::is_uint || llvm_value_t::is_float, "llvm_neg<>: invalid type"); - static constexpr auto opc = llvm_value_t::is_float ? llvm::Instruction::FSub : llvm::Instruction::Sub; + static constexpr auto opc = llvm_value_t::is_float ? llvm::Instruction::FNeg : llvm::Instruction::Sub; llvm::Value* eval(llvm::IRBuilder<>* ir) const { @@ -849,6 +849,19 @@ struct llvm_neg { llvm::Value* v1 = {}; + if constexpr (llvm_value_t::is_float) + { + if (auto i = llvm::dyn_cast_or_null(value); i && i->getOpcode() == opc) + { + v1 = i->getOperand(0); + + if (auto r1 = a1.match(v1); v1) + { + return r1; + } + } + } + if (auto i = llvm::dyn_cast_or_null(value); i && i->getOpcode() == opc) { v1 = i->getOperand(1);