Fix AArch64 MOVI2R helper function.
In the case of a zero immediate, it wouldn't generate code at all. Also in the case of max u32/u64, use ORN to optimize it.
This commit is contained in:
parent
64b21a4812
commit
17d31ecd6c
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include "Arm64Emitter.h"
|
#include "Arm64Emitter.h"
|
||||||
|
|
||||||
namespace Arm64Gen
|
namespace Arm64Gen
|
||||||
|
@ -1341,6 +1343,23 @@ void ARM64XEmitter::MOVI2R(ARM64Reg Rd, u64 imm, bool optimize)
|
||||||
if (!Is64Bit(Rd))
|
if (!Is64Bit(Rd))
|
||||||
_assert_msg_(DYNA_REC, !(imm >> 32), "%s: immediate doesn't fit in 32bit register: %lx", __FUNCTION__, imm);
|
_assert_msg_(DYNA_REC, !(imm >> 32), "%s: immediate doesn't fit in 32bit register: %lx", __FUNCTION__, imm);
|
||||||
|
|
||||||
|
if (!imm)
|
||||||
|
{
|
||||||
|
// Zero immediate, just clear the register
|
||||||
|
EOR(Rd, Rd, Rd, ArithOption(Rd, ST_LSL, 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Is64Bit(Rd) && imm == std::numeric_limits<u64>::max()) ||
|
||||||
|
(!Is64Bit(Rd) && imm == std::numeric_limits<u32>::max()))
|
||||||
|
{
|
||||||
|
// Max unsigned value
|
||||||
|
// Set to ~ZR
|
||||||
|
ARM64Reg ZR = Is64Bit(Rd) ? SP : WSP;
|
||||||
|
ORN(Rd, Rd, ZR, ArithOption(ZR, ST_LSL, 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// XXX: Optimize more
|
// XXX: Optimize more
|
||||||
// XXX: Support rotating immediates to save instructions
|
// XXX: Support rotating immediates to save instructions
|
||||||
if (optimize)
|
if (optimize)
|
||||||
|
|
Loading…
Reference in New Issue