summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorJonas Paulsson <jonas.paulsson@ericsson.com>2015-10-26 15:03:07 +0000
committerJonas Paulsson <jonas.paulsson@ericsson.com>2015-10-26 15:03:07 +0000
commitdab740725847c1f4c828e9f20449901c23bebf1e (patch)
tree6cbfa228ea06f15d364f0dde95d1f944e120e5b8 /llvm/lib/Target
parent165121f3261133eb9c587d6ac68a31a59f79891b (diff)
downloadbcm5719-llvm-dab740725847c1f4c828e9f20449901c23bebf1e.tar.gz
bcm5719-llvm-dab740725847c1f4c828e9f20449901c23bebf1e.zip
[SystemZ] Tie operands in SystemZShorteInst if MI becomes 2-address.
Discovered by testing fp-add-02.ll with -verify-machineinstrs. Test case updated to always run with -verify-machineinstrs. llvm-svn: 251296
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZShortenInst.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZShortenInst.cpp b/llvm/lib/Target/SystemZ/SystemZShortenInst.cpp
index 87db4f46fcd..846edd51341 100644
--- a/llvm/lib/Target/SystemZ/SystemZShortenInst.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZShortenInst.cpp
@@ -59,6 +59,13 @@ FunctionPass *llvm::createSystemZShortenInstPass(SystemZTargetMachine &TM) {
SystemZShortenInst::SystemZShortenInst(const SystemZTargetMachine &tm)
: MachineFunctionPass(ID), TII(nullptr) {}
+// Tie operands if MI has become a two-address instruction.
+static void tieOpsIfNeeded(MachineInstr &MI) {
+ if (MI.getDesc().getOperandConstraint(0, MCOI::TIED_TO) &&
+ !MI.getOperand(0).isTied())
+ MI.tieOperands(0, 1);
+}
+
// MI loads one word of a GPR using an IIxF instruction and LLIxL and LLIxH
// are the halfword immediate loads for the same word. Try to use one of them
// instead of IIxF.
@@ -113,12 +120,14 @@ bool SystemZShortenInst::shortenOn01(MachineInstr &MI, unsigned Opcode) {
}
// Change MI's opcode to Opcode if register operands 0, 1 and 2 have a
-// 4-bit encoding and if operands 0 and 1 are tied.
+// 4-bit encoding and if operands 0 and 1 are tied. Also ties op 0
+// with op 1, if MI becomes 2-address.
bool SystemZShortenInst::shortenOn001(MachineInstr &MI, unsigned Opcode) {
if (SystemZMC::getFirstReg(MI.getOperand(0).getReg()) < 16 &&
MI.getOperand(1).getReg() == MI.getOperand(0).getReg() &&
SystemZMC::getFirstReg(MI.getOperand(2).getReg()) < 16) {
MI.setDesc(TII->get(Opcode));
+ tieOpsIfNeeded(MI);
return true;
}
return false;
OpenPOWER on IntegriCloud