From a9a454faf73172cc5c9dd2ab03a54f4437132a9c Mon Sep 17 00:00:00 2001 From: elad335 <18193363+elad335@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:12:50 +0300 Subject: [PATCH] asm: Fix utils::rational_mul optimization --- rpcs3/util/asm.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index e64939ab88..f59941dee9 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -410,10 +410,12 @@ namespace utils return static_cast(value * u64{numerator} / u64{denominator}); } +#if is_u128_emulated if constexpr (sizeof(T) <= sizeof(u128) / 2) { - return static_cast(value * u128{numerator} / u64{denominator}); + return static_cast(u128_from_mul(value, numerator) / u64{denominator}); } +#endif return static_cast(value / denominator * numerator + (value % denominator) * numerator / denominator); }