diff options
| author | Weiming Zhao <weimingz@codeaurora.org> | 2015-07-23 19:24:53 +0000 |
|---|---|---|
| committer | Weiming Zhao <weimingz@codeaurora.org> | 2015-07-23 19:24:53 +0000 |
| commit | b33a5557f47592800f538353b4c556d2b8dd12fa (patch) | |
| tree | 61608a17d1ce8eae155b00695809a9ea525903e9 /llvm/lib | |
| parent | c96dcb09148518694528b8d7e9ae4235b4a7f62e (diff) | |
| download | bcm5719-llvm-b33a5557f47592800f538353b4c556d2b8dd12fa.tar.gz bcm5719-llvm-b33a5557f47592800f538353b4c556d2b8dd12fa.zip | |
This patch eanble register coalescing to coalesce the following:
%vreg2<def> = MOVi32imm 1; GPR32:%vreg2
%W1<def> = COPY %vreg2; GPR32:%vreg2
into:
%W1<def> = MOVi32imm 1
Patched by Lawrence Hu (lawrence@codeaurora.org)
llvm-svn: 243033
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index f5b0c8b450a..66b89366c2d 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -533,6 +533,14 @@ void AArch64InstrInfo::insertSelect(MachineBasicBlock &MBB, CC); } +/// Returns true if a MOVi32imm or MOVi64imm can be expanded to an ORRxx. +static bool canBeExpandedToORR(const MachineInstr *MI, unsigned BitSize) { + uint64_t Imm = MI->getOperand(1).getImm(); + uint64_t UImm = Imm << (64 - BitSize) >> (64 - BitSize); + uint64_t Encoding; + return AArch64_AM::processLogicalImmediate(UImm, BitSize, Encoding); +} + // FIXME: this implementation should be micro-architecture dependent, so a // micro-architecture target hook should be introduced here in future. bool AArch64InstrInfo::isAsCheapAsAMove(const MachineInstr *MI) const { @@ -573,6 +581,12 @@ bool AArch64InstrInfo::isAsCheapAsAMove(const MachineInstr *MI) const { case AArch64::ORRWrr: case AArch64::ORRXrr: return true; + // If MOVi32imm or MOVi64imm can be expanded into ORRWri or + // ORRXri, it is as cheap as MOV + case AArch64::MOVi32imm: + return canBeExpandedToORR(MI, 32); + case AArch64::MOVi64imm: + return canBeExpandedToORR(MI, 64); } llvm_unreachable("Unknown opcode to check as cheap as a move!"); |

