[llvm] r352093 - [LICM] Cleanup duplicated code. [NFCI]
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 11:57:30 PST 2019
Author: asbirlea
Date: Thu Jan 24 11:57:30 2019
New Revision: 352093
URL: http://llvm.org/viewvc/llvm-project?rev=352093&view=rev
Log:
[LICM] Cleanup duplicated code. [NFCI]
Modified:
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=352093&r1=352092&r2=352093&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Thu Jan 24 11:57:30 2019
@@ -148,7 +148,8 @@ static void eraseInstruction(Instruction
AliasSetTracker *AST, MemorySSAUpdater *MSSAU);
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
- ICFLoopSafetyInfo &SafetyInfo);
+ ICFLoopSafetyInfo &SafetyInfo,
+ MemorySSAUpdater *MSSAU);
namespace {
struct LoopInvariantCodeMotion {
@@ -866,12 +867,7 @@ bool llvm::hoistRegion(DomTreeNode *N, A
LLVM_DEBUG(dbgs() << "LICM rehoisting to "
<< HoistPoint->getParent()->getName()
<< ": " << *I << "\n");
- moveInstructionBefore(*I, *HoistPoint, *SafetyInfo);
- if (MSSAU)
- if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
- MSSAU->getMemorySSA()->getMemoryAccess(I)))
- MSSAU->moveToPlace(OldMemAcc, HoistPoint->getParent(),
- MemorySSA::End);
+ moveInstructionBefore(*I, *HoistPoint, *SafetyInfo, MSSAU);
HoistPoint = I;
Changed = true;
}
@@ -1314,10 +1310,15 @@ static void eraseInstruction(Instruction
}
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
- ICFLoopSafetyInfo &SafetyInfo) {
+ ICFLoopSafetyInfo &SafetyInfo,
+ MemorySSAUpdater *MSSAU) {
SafetyInfo.removeInstruction(&I);
SafetyInfo.insertInstructionTo(&I, Dest.getParent());
I.moveBefore(&Dest);
+ if (MSSAU)
+ if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
+ MSSAU->getMemorySSA()->getMemoryAccess(&I)))
+ MSSAU->moveToPlace(OldMemAcc, Dest->getParent(), MemorySSA::End);
}
static Instruction *sinkThroughTriviallyReplaceablePHI(
@@ -1553,17 +1554,10 @@ static void hoist(Instruction &I, const
if (isa<PHINode>(I))
// Move the new node to the end of the phi list in the destination block.
- moveInstructionBefore(I, *Dest->getFirstNonPHI(), *SafetyInfo);
+ moveInstructionBefore(I, *Dest->getFirstNonPHI(), *SafetyInfo, MSSAU);
else
// Move the new node to the destination block, before its terminator.
- moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo);
- if (MSSAU) {
- // If moving, I just moved a load or store, so update MemorySSA.
- MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
- MSSAU->getMemorySSA()->getMemoryAccess(&I));
- if (OldMemAcc)
- MSSAU->moveToPlace(OldMemAcc, Dest, MemorySSA::End);
- }
+ moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo, MSSAU);
// Do not retain debug locations when we are moving instructions to different
// basic blocks, because we want to avoid jumpy line tables. Calls, however,
More information about the llvm-commits
mailing list