From d0b849aad74e44e66c1590535785e93a001eba50 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Thu, 10 Dec 2020 21:34:37 +0300 Subject: [PATCH] [PPC] vcfsx/vcfux: Only mul if needed --- src/xenia/cpu/ppc/ppc_emit_altivec.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/xenia/cpu/ppc/ppc_emit_altivec.cc b/src/xenia/cpu/ppc/ppc_emit_altivec.cc index 9c53e61ce..770def3c1 100644 --- a/src/xenia/cpu/ppc/ppc_emit_altivec.cc +++ b/src/xenia/cpu/ppc/ppc_emit_altivec.cc @@ -519,9 +519,11 @@ int InstrEmit_vavguw(PPCHIRBuilder& f, const InstrData& i) { int InstrEmit_vcfsx_(PPCHIRBuilder& f, uint32_t vd, uint32_t vb, uint32_t uimm) { // (VD) <- float(VB as signed) / 2^uimm - float fuimm = std::ldexp(1.0f, -int32_t(uimm)); - Value* v = f.Mul(f.VectorConvertI2F(f.LoadVR(vb)), - f.Splat(f.LoadConstantFloat32(fuimm), VEC128_TYPE)); + Value* v = f.VectorConvertI2F(f.LoadVR(vb)); + if (uimm) { + float fuimm = std::ldexp(1.0f, -int(uimm)); + v = f.Mul(v, f.Splat(f.LoadConstantFloat32(fuimm), VEC128_TYPE)); + } f.StoreVR(vd, v); return 0; } @@ -535,9 +537,11 @@ int InstrEmit_vcsxwfp128(PPCHIRBuilder& f, const InstrData& i) { int InstrEmit_vcfux_(PPCHIRBuilder& f, uint32_t vd, uint32_t vb, uint32_t uimm) { // (VD) <- float(VB as unsigned) / 2^uimm - float fuimm = std::ldexp(1.0f, -int32_t(uimm)); - Value* v = f.Mul(f.VectorConvertI2F(f.LoadVR(vb), ARITHMETIC_UNSIGNED), - f.Splat(f.LoadConstantFloat32(fuimm), VEC128_TYPE)); + Value* v = f.VectorConvertI2F(f.LoadVR(vb), ARITHMETIC_UNSIGNED); + if (uimm) { + float fuimm = std::ldexp(1.0f, -int(uimm)); + v = f.Mul(v, f.Splat(f.LoadConstantFloat32(fuimm), VEC128_TYPE)); + } f.StoreVR(vd, v); return 0; }