diff options
Diffstat (limited to 'lib/Target/SystemZ/SystemZShortenInst.cpp')
-rw-r--r-- | lib/Target/SystemZ/SystemZShortenInst.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/Target/SystemZ/SystemZShortenInst.cpp b/lib/Target/SystemZ/SystemZShortenInst.cpp index 846edd51341a7..7f26a3519e50f 100644 --- a/lib/Target/SystemZ/SystemZShortenInst.cpp +++ b/lib/Target/SystemZ/SystemZShortenInst.cpp @@ -35,6 +35,10 @@ public: bool processBlock(MachineBasicBlock &MBB); bool runOnMachineFunction(MachineFunction &F) override; + MachineFunctionProperties getRequiredProperties() const override { + return MachineFunctionProperties().set( + MachineFunctionProperties::Property::AllVRegsAllocated); + } private: bool shortenIIF(MachineInstr &MI, unsigned LLIxL, unsigned LLIxH); @@ -68,18 +72,20 @@ static void tieOpsIfNeeded(MachineInstr &MI) { // 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. -bool SystemZShortenInst::shortenIIF(MachineInstr &MI, - unsigned LLIxL, unsigned LLIxH) { +// instead of IIxF. +bool SystemZShortenInst::shortenIIF(MachineInstr &MI, unsigned LLIxL, + unsigned LLIxH) { unsigned Reg = MI.getOperand(0).getReg(); // The new opcode will clear the other half of the GR64 reg, so // cancel if that is live. - unsigned thisSubRegIdx = (SystemZ::GRH32BitRegClass.contains(Reg) ? - SystemZ::subreg_h32 : SystemZ::subreg_l32); - unsigned otherSubRegIdx = (thisSubRegIdx == SystemZ::subreg_l32 ? - SystemZ::subreg_h32 : SystemZ::subreg_l32); - unsigned GR64BitReg = TRI->getMatchingSuperReg(Reg, thisSubRegIdx, - &SystemZ::GR64BitRegClass); + unsigned thisSubRegIdx = + (SystemZ::GRH32BitRegClass.contains(Reg) ? SystemZ::subreg_h32 + : SystemZ::subreg_l32); + unsigned otherSubRegIdx = + (thisSubRegIdx == SystemZ::subreg_l32 ? SystemZ::subreg_h32 + : SystemZ::subreg_l32); + unsigned GR64BitReg = + TRI->getMatchingSuperReg(Reg, thisSubRegIdx, &SystemZ::GR64BitRegClass); unsigned OtherReg = TRI->getSubReg(GR64BitReg, otherSubRegIdx); if (LiveRegs.contains(OtherReg)) return false; @@ -135,11 +141,10 @@ bool SystemZShortenInst::shortenOn001(MachineInstr &MI, unsigned Opcode) { // Calls shortenOn001 if CCLive is false. CC def operand is added in // case of success. -bool SystemZShortenInst::shortenOn001AddCC(MachineInstr &MI, - unsigned Opcode) { +bool SystemZShortenInst::shortenOn001AddCC(MachineInstr &MI, unsigned Opcode) { if (!LiveRegs.contains(SystemZ::CC) && shortenOn001(MI, Opcode)) { MachineInstrBuilder(*MI.getParent()->getParent(), &MI) - .addReg(SystemZ::CC, RegState::ImplicitDefine); + .addReg(SystemZ::CC, RegState::ImplicitDefine | RegState::Dead); return true; } return false; @@ -177,7 +182,7 @@ bool SystemZShortenInst::processBlock(MachineBasicBlock &MBB) { // Set up the set of live registers at the end of MBB (live out) LiveRegs.clear(); - LiveRegs.addLiveOuts(&MBB); + LiveRegs.addLiveOuts(MBB); // Iterate backwards through the block looking for instructions to change. for (auto MBBI = MBB.rbegin(), MBBE = MBB.rend(); MBBI != MBBE; ++MBBI) { @@ -264,6 +269,9 @@ bool SystemZShortenInst::processBlock(MachineBasicBlock &MBB) { } bool SystemZShortenInst::runOnMachineFunction(MachineFunction &F) { + if (skipFunction(*F.getFunction())) + return false; + const SystemZSubtarget &ST = F.getSubtarget<SystemZSubtarget>(); TII = ST.getInstrInfo(); TRI = ST.getRegisterInfo(); |