diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-14 15:21:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-14 15:21:58 +0000 |
commit | 8db2cd1fc767086f65b5f93d9c7b4c1924774775 (patch) | |
tree | 273e8c91fb2516b8481fc88b8d031cfeca9f3d43 /lib | |
parent | 5da60469f9a9513c28c9d715d818f7d789972e90 (diff) | |
download | external_llvm-8db2cd1fc767086f65b5f93d9c7b4c1924774775.tar.gz external_llvm-8db2cd1fc767086f65b5f93d9c7b4c1924774775.tar.bz2 external_llvm-8db2cd1fc767086f65b5f93d9c7b4c1924774775.zip |
make instcombine's instruction sinking more aggressive in the
presence of PHI nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84103 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 88421db826..50d6d99e9b 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -12836,7 +12836,15 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { // See if we can trivially sink this instruction to a successor basic block. if (I->hasOneUse()) { BasicBlock *BB = I->getParent(); - BasicBlock *UserParent = cast<Instruction>(I->use_back())->getParent(); + Instruction *UserInst = cast<Instruction>(I->use_back()); + BasicBlock *UserParent; + + // Get the block the use occurs in. + if (PHINode *PN = dyn_cast<PHINode>(UserInst)) + UserParent = PN->getIncomingBlock(I->use_begin().getUse()); + else + UserParent = UserInst->getParent(); + if (UserParent != BB) { bool UserIsSuccessor = false; // See if the user is one of our successors. @@ -12849,8 +12857,7 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { // If the user is one of our immediate successors, and if that successor // only has us as a predecessors (we'd have to split the critical edge // otherwise), we can keep going. - if (UserIsSuccessor && !isa<PHINode>(I->use_back()) && - next(pred_begin(UserParent)) == pred_end(UserParent)) + if (UserIsSuccessor && UserParent->getSinglePredecessor()) // Okay, the CFG is simple enough, try to sink this instruction. MadeIRChange |= TryToSinkInstruction(I, UserParent); } |