[llvm] r343489 - [AArch64] Refactor cheap cost model
Evandro Menezes via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 1 09:11:19 PDT 2018
Author: evandro
Date: Mon Oct 1 09:11:19 2018
New Revision: 343489
URL: http://llvm.org/viewvc/llvm-project?rev=343489&view=rev
Log:
[AArch64] Refactor cheap cost model
Refactor the order in `TII::isAsCheapAsAMove()` to ease future development
and maintenance. Practically NFC.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp?rev=343489&r1=343488&r2=343489&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp Mon Oct 1 09:11:19 2018
@@ -675,6 +675,26 @@ bool AArch64InstrInfo::isAsCheapAsAMove(
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(
return MI.isAsCheapAsAMove();
}
- switch (MI.getOpcode()) {
+ // Finally, check generic cases.
+
+ switch (Opcode) {
default:
return false;
@@ -723,17 +745,6 @@ bool AArch64InstrInfo::isAsCheapAsAMove(
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!");
More information about the llvm-commits
mailing list