summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
diff options
context:
space:
mode:
authorZaara Syeda <syzaara@ca.ibm.com>2017-11-27 20:26:36 +0000
committerZaara Syeda <syzaara@ca.ibm.com>2017-11-27 20:26:36 +0000
commitf94d58d90864600143885468e95621dcfc8b4365 (patch)
treeec885a6fdb516dfba70b61971c0a186909dd4ac5 /llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
parenteef5c233058eb98b22b7271f20b82974cb664571 (diff)
downloadbcm5719-llvm-f94d58d90864600143885468e95621dcfc8b4365.tar.gz
bcm5719-llvm-f94d58d90864600143885468e95621dcfc8b4365.zip
[PowerPC] Remove redundant TOC saves
This patch adds a peep hole optimization to remove any redundant toc save instructions added as part of the call sequence for indirect calls. It removes any toc saves within a function that are dominated by another toc save. Differential Revision: https://reviews.llvm.org/D39736 llvm-svn: 319087
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCInstrInfo.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCInstrInfo.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index 99a52902a52..f25b929c808 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2266,6 +2266,20 @@ static bool isZeroExtendingOp(const MachineInstr &MI) {
return false;
}
+// This function returns true if the input MachineInstr is a TOC save
+// instruction.
+bool PPCInstrInfo::isTOCSaveMI(const MachineInstr &MI) const {
+ if (!MI.getOperand(1).isImm() || !MI.getOperand(2).isReg())
+ return false;
+ unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
+ unsigned StackOffset = MI.getOperand(1).getImm();
+ unsigned StackReg = MI.getOperand(2).getReg();
+ if (StackReg == PPC::X1 && StackOffset == TOCSaveOffset)
+ return true;
+
+ return false;
+}
+
// We limit the max depth to track incoming values of PHIs or binary ops
// (e.g. AND) to avoid exsessive cost.
const unsigned MAX_DEPTH = 1;
OpenPOWER on IntegriCloud