diff options
Diffstat (limited to 'contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp')
| -rw-r--r-- | contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 55 | 
1 files changed, 32 insertions, 23 deletions
diff --git a/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp index e419b9b40d8e..ec1e34d91f93 100644 --- a/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp +++ b/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp @@ -23,31 +23,29 @@  //  //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "ctrloops" -  #include "llvm/Transforms/Scalar.h" -#include "llvm/ADT/Statistic.h" +#include "PPC.h" +#include "PPCTargetMachine.h"  #include "llvm/ADT/STLExtras.h" -#include "llvm/Analysis/Dominators.h" +#include "llvm/ADT/Statistic.h"  #include "llvm/Analysis/LoopInfo.h"  #include "llvm/Analysis/ScalarEvolutionExpander.h"  #include "llvm/IR/Constants.h"  #include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Dominators.h"  #include "llvm/IR/InlineAsm.h"  #include "llvm/IR/Instructions.h"  #include "llvm/IR/IntrinsicInst.h"  #include "llvm/IR/Module.h" +#include "llvm/IR/ValueHandle.h"  #include "llvm/PassSupport.h"  #include "llvm/Support/CommandLine.h"  #include "llvm/Support/Debug.h" -#include "llvm/Support/ValueHandle.h"  #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetLibraryInfo.h"  #include "llvm/Transforms/Utils/BasicBlockUtils.h"  #include "llvm/Transforms/Utils/Local.h"  #include "llvm/Transforms/Utils/LoopUtils.h" -#include "llvm/Target/TargetLibraryInfo.h" -#include "PPCTargetMachine.h" -#include "PPC.h"  #ifndef NDEBUG  #include "llvm/CodeGen/MachineDominators.h" @@ -61,6 +59,8 @@  using namespace llvm; +#define DEBUG_TYPE "ctrloops" +  #ifndef NDEBUG  static cl::opt<int> CTRLoopLimit("ppc-max-ctrloop", cl::Hidden, cl::init(-1));  #endif @@ -84,20 +84,20 @@ namespace {    public:      static char ID; -    PPCCTRLoops() : FunctionPass(ID), TM(0) { +    PPCCTRLoops() : FunctionPass(ID), TM(nullptr) {        initializePPCCTRLoopsPass(*PassRegistry::getPassRegistry());      }      PPCCTRLoops(PPCTargetMachine &TM) : FunctionPass(ID), TM(&TM) {        initializePPCCTRLoopsPass(*PassRegistry::getPassRegistry());      } -    virtual bool runOnFunction(Function &F); +    bool runOnFunction(Function &F) override; -    virtual void getAnalysisUsage(AnalysisUsage &AU) const { +    void getAnalysisUsage(AnalysisUsage &AU) const override {        AU.addRequired<LoopInfo>();        AU.addPreserved<LoopInfo>(); -      AU.addRequired<DominatorTree>(); -      AU.addPreserved<DominatorTree>(); +      AU.addRequired<DominatorTreeWrapperPass>(); +      AU.addPreserved<DominatorTreeWrapperPass>();        AU.addRequired<ScalarEvolution>();      } @@ -109,7 +109,7 @@ namespace {      PPCTargetMachine *TM;      LoopInfo *LI;      ScalarEvolution *SE; -    DataLayout *TD; +    const DataLayout *DL;      DominatorTree *DT;      const TargetLibraryInfo *LibInfo;    }; @@ -128,12 +128,12 @@ namespace {        initializePPCCTRLoopsVerifyPass(*PassRegistry::getPassRegistry());      } -    virtual void getAnalysisUsage(AnalysisUsage &AU) const { +    void getAnalysisUsage(AnalysisUsage &AU) const override {        AU.addRequired<MachineDominatorTree>();        MachineFunctionPass::getAnalysisUsage(AU);      } -    virtual bool runOnMachineFunction(MachineFunction &MF); +    bool runOnMachineFunction(MachineFunction &MF) override;    private:      MachineDominatorTree *MDT; @@ -145,7 +145,7 @@ namespace {  INITIALIZE_PASS_BEGIN(PPCCTRLoops, "ppc-ctr-loops", "PowerPC CTR Loops",                        false, false) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)  INITIALIZE_PASS_DEPENDENCY(LoopInfo)  INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)  INITIALIZE_PASS_END(PPCCTRLoops, "ppc-ctr-loops", "PowerPC CTR Loops", @@ -170,8 +170,9 @@ FunctionPass *llvm::createPPCCTRLoopsVerify() {  bool PPCCTRLoops::runOnFunction(Function &F) {    LI = &getAnalysis<LoopInfo>();    SE = &getAnalysis<ScalarEvolution>(); -  DT = &getAnalysis<DominatorTree>(); -  TD = getAnalysisIfAvailable<DataLayout>(); +  DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); +  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); +  DL = DLP ? &DLP->getDataLayout() : nullptr;    LibInfo = getAnalysisIfAvailable<TargetLibraryInfo>();    bool MadeChange = false; @@ -188,7 +189,7 @@ bool PPCCTRLoops::runOnFunction(Function &F) {  static bool isLargeIntegerTy(bool Is32Bit, Type *Ty) {    if (IntegerType *ITy = dyn_cast<IntegerType>(Ty)) -    return ITy->getBitWidth() > (Is32Bit ? 32 : 64); +    return ITy->getBitWidth() > (Is32Bit ? 32U : 64U);    return false;  } @@ -369,6 +370,14 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) {                  J->getOpcode() == Instruction::URem ||                  J->getOpcode() == Instruction::SRem)) {        return true; +    } else if (TT.isArch32Bit() && +               isLargeIntegerTy(false, J->getType()->getScalarType()) && +               (J->getOpcode() == Instruction::Shl || +                J->getOpcode() == Instruction::AShr || +                J->getOpcode() == Instruction::LShr)) { +      // Only on PPC32, for 128-bit integers (specifically not 64-bit +      // integers), these might be runtime calls. +      return true;      } else if (isa<IndirectBrInst>(J) || isa<InvokeInst>(J)) {        // On PowerPC, indirect jumps use the counter register.        return true; @@ -423,9 +432,9 @@ bool PPCCTRLoops::convertToCTRLoop(Loop *L) {    SmallVector<BasicBlock*, 4> ExitingBlocks;    L->getExitingBlocks(ExitingBlocks); -  BasicBlock *CountedExitBlock = 0; -  const SCEV *ExitCount = 0; -  BranchInst *CountedExitBranch = 0; +  BasicBlock *CountedExitBlock = nullptr; +  const SCEV *ExitCount = nullptr; +  BranchInst *CountedExitBranch = nullptr;    for (SmallVectorImpl<BasicBlock *>::iterator I = ExitingBlocks.begin(),         IE = ExitingBlocks.end(); I != IE; ++I) {      const SCEV *EC = SE->getExitCount(L, *I);  | 
