From f355600c205f328c843e1b2e7ffc1d2a917c4b6e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Jun 2015 20:13:41 -0700 Subject: [PATCH] arm64: Handle negative MOVI2F more correctly. Both -0.0 and some negated constant values were handled wrong. --- Common/Arm64Emitter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Common/Arm64Emitter.cpp b/Common/Arm64Emitter.cpp index 8865ba3bb8..ebf0a9101a 100644 --- a/Common/Arm64Emitter.cpp +++ b/Common/Arm64Emitter.cpp @@ -3562,13 +3562,21 @@ void ARM64FloatEmitter::MOVI2F(ARM64Reg Rd, float value, ARM64Reg scratch, bool _assert_msg_(JIT, !IsDouble(Rd), "MOVI2F does not yet support double precision"); uint8_t imm8; if (value == 0.0) { + if (std::signbit(value)) { + negate = !negate; + } FMOV(Rd, IsDouble(Rd) ? ZR : WZR); if (negate) { FNEG(Rd, Rd); } // TODO: There are some other values we could generate with the float-imm instruction, like 1.0... + } else if (negate && FPImm8FromFloat(-value, &imm8)) { + FMOV(Rd, imm8); } else if (FPImm8FromFloat(value, &imm8)) { FMOV(Rd, imm8); + if (negate) { + FNEG(Rd, Rd); + } } else { _assert_msg_(JIT, scratch != INVALID_REG, "Failed to find a way to generate FP immediate %f without scratch", value); u32 ival;