diff options
| author | Evandro Menezes <e.menezes@samsung.com> | 2018-10-01 16:11:19 +0000 |
|---|---|---|
| committer | Evandro Menezes <e.menezes@samsung.com> | 2018-10-01 16:11:19 +0000 |
| commit | 55b9a5395ba605e95b3430ce5d6d9d0078e74463 (patch) | |
| tree | 92d5be7180a26d98458d9ac2692e24514be22815 | |
| parent | 392237754452a3d882f1be8486279d93a296148c (diff) | |
| download | bcm5719-llvm-55b9a5395ba605e95b3430ce5d6d9d0078e74463.tar.gz bcm5719-llvm-55b9a5395ba605e95b3430ce5d6d9d0078e74463.zip | |
[AArch64] Refactor cheap cost model
Refactor the order in `TII::isAsCheapAsAMove()` to ease future development
and maintenance. Practically NFC.
llvm-svn: 343489
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 5c097be67c3..da555665a75 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -675,6 +675,26 @@ bool AArch64InstrInfo::isAsCheapAsAMove(const MachineInstr &MI) const { if (!Subtarget.hasCustomCheapAsMoveHandling()) return MI.isAsCheapAsAMove(); + const unsigned Opcode = MI.getOpcode(); + + // Firstly, check cases gated by features. + + if (Subtarget.hasZeroCycleZeroingFP()) { + if (Opcode == AArch64::FMOVH0 || + Opcode == AArch64::FMOVS0 || + Opcode == AArch64::FMOVD0) + return true; + } + + if (Subtarget.hasZeroCycleZeroingGP()) { + if (Opcode == TargetOpcode::COPY && + (MI.getOperand(1).getReg() == AArch64::WZR || + MI.getOperand(1).getReg() == AArch64::XZR)) + return true; + } + + // Secondly, check cases specific to sub-targets. + if (Subtarget.hasExynosCheapAsMoveHandling()) { if (isExynosResetFast(MI) || isExynosShiftLeftFast(MI)) return true; @@ -682,7 +702,9 @@ bool AArch64InstrInfo::isAsCheapAsAMove(const MachineInstr &MI) const { return MI.isAsCheapAsAMove(); } - switch (MI.getOpcode()) { + // Finally, check generic cases. + + switch (Opcode) { default: return false; @@ -723,17 +745,6 @@ bool AArch64InstrInfo::isAsCheapAsAMove(const MachineInstr &MI) const { return canBeExpandedToORR(MI, 32); case AArch64::MOVi64imm: return canBeExpandedToORR(MI, 64); - - // It is cheap to zero out registers if the subtarget has ZeroCycleZeroing - // feature. - case AArch64::FMOVH0: - case AArch64::FMOVS0: - case AArch64::FMOVD0: - return Subtarget.hasZeroCycleZeroingFP(); - case TargetOpcode::COPY: - return (Subtarget.hasZeroCycleZeroingGP() && - (MI.getOperand(1).getReg() == AArch64::WZR || - MI.getOperand(1).getReg() == AArch64::XZR)); } llvm_unreachable("Unknown opcode to check as cheap as a move!"); |

