diff options
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCMIPeephole.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp index c8b01aaef828..4bbb6ed85a6c 100644 --- a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp +++ b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp @@ -226,28 +226,30 @@ getKnownLeadingZeroCount(MachineInstr *MI, const PPCInstrInfo *TII) { void PPCMIPeephole::UpdateTOCSaves( std::map<MachineInstr *, bool> &TOCSaves, MachineInstr *MI) { assert(TII->isTOCSaveMI(*MI) && "Expecting a TOC save instruction here"); - assert(MF->getSubtarget<PPCSubtarget>().isELFv2ABI() && - "TOC-save removal only supported on ELFv2"); - PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>(); - - MachineBasicBlock *Entry = &MF->front(); - uint64_t CurrBlockFreq = MBFI->getBlockFreq(MI->getParent()).getFrequency(); - - // If the block in which the TOC save resides is in a block that - // post-dominates Entry, or a block that is hotter than entry (keep in mind - // that early MachineLICM has already run so the TOC save won't be hoisted) - // we can just do the save in the prologue. - if (CurrBlockFreq > EntryFreq || MPDT->dominates(MI->getParent(), Entry)) - FI->setMustSaveTOC(true); - - // If we are saving the TOC in the prologue, all the TOC saves can be removed - // from the code. - if (FI->mustSaveTOC()) { - for (auto &TOCSave : TOCSaves) - TOCSave.second = false; - // Add new instruction to map. - TOCSaves[MI] = false; - return; + // FIXME: Saving TOC in prologue hasn't been implemented well in AIX ABI part, + // here only support it under ELFv2. + if (MF->getSubtarget<PPCSubtarget>().isELFv2ABI()) { + PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>(); + + MachineBasicBlock *Entry = &MF->front(); + uint64_t CurrBlockFreq = MBFI->getBlockFreq(MI->getParent()).getFrequency(); + + // If the block in which the TOC save resides is in a block that + // post-dominates Entry, or a block that is hotter than entry (keep in mind + // that early MachineLICM has already run so the TOC save won't be hoisted) + // we can just do the save in the prologue. + if (CurrBlockFreq > EntryFreq || MPDT->dominates(MI->getParent(), Entry)) + FI->setMustSaveTOC(true); + + // If we are saving the TOC in the prologue, all the TOC saves can be + // removed from the code. + if (FI->mustSaveTOC()) { + for (auto &TOCSave : TOCSaves) + TOCSave.second = false; + // Add new instruction to map. + TOCSaves[MI] = false; + return; + } } bool Keep = true; @@ -476,10 +478,12 @@ bool PPCMIPeephole::simplifyCode(void) { } break; } + case PPC::STW: case PPC::STD: { MachineFrameInfo &MFI = MF->getFrameInfo(); if (MFI.hasVarSizedObjects() || - !MF->getSubtarget<PPCSubtarget>().isELFv2ABI()) + (!MF->getSubtarget<PPCSubtarget>().isELFv2ABI() && + !MF->getSubtarget<PPCSubtarget>().isAIXABI())) break; // When encountering a TOC save instruction, call UpdateTOCSaves // to add it to the TOCSaves map and mark any existing TOC saves @@ -660,7 +664,8 @@ bool PPCMIPeephole::simplifyCode(void) { Register ShiftOp1 = DefMI->getOperand(1).getReg(); Register ShiftOp2 = DefMI->getOperand(2).getReg(); unsigned ShiftImm = DefMI->getOperand(3).getImm(); - unsigned SplatImm = MI.getOperand(2).getImm(); + unsigned SplatImm = + MI.getOperand(MyOpcode == PPC::XXSPLTW ? 2 : 1).getImm(); if (ShiftOp1 == ShiftOp2) { unsigned NewElem = (SplatImm + ShiftImm) & 0x3; if (MRI->hasOneNonDBGUse(ShiftRes)) { |