[PATCH] D27110: [GVNHoist] Early exit of cheap computations
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 24 10:31:03 PST 2016
hiraditya updated this revision to Diff 79247.
https://reviews.llvm.org/D27110
Files:
lib/Transforms/Scalar/GVNHoist.cpp
Index: lib/Transforms/Scalar/GVNHoist.cpp
===================================================================
--- lib/Transforms/Scalar/GVNHoist.cpp
+++ lib/Transforms/Scalar/GVNHoist.cpp
@@ -391,18 +391,18 @@
continue;
}
+ // Stop walk once the limit is reached.
+ if (NBBsOnAllPaths == 0)
+ return true;
+
// Impossible to hoist with exceptions on the path.
if (hasEH(*I))
return true;
// Check that we do not move a store past loads.
if (hasMemoryUse(NewPt, Def, *I))
return true;
- // Stop walk once the limit is reached.
- if (NBBsOnAllPaths == 0)
- return true;
-
// -1 is unlimited number of blocks on all paths.
if (NBBsOnAllPaths != -1)
--NBBsOnAllPaths;
@@ -433,14 +433,14 @@
continue;
}
- // Impossible to hoist with exceptions on the path.
- if (hasEH(*I))
- return true;
-
// Stop walk once the limit is reached.
if (NBBsOnAllPaths == 0)
return true;
+ // Impossible to hoist with exceptions on the path.
+ if (hasEH(*I))
+ return true;
+
// -1 is unlimited number of blocks on all paths.
if (NBBsOnAllPaths != -1)
--NBBsOnAllPaths;
@@ -530,7 +530,7 @@
std::sort(InstructionsToHoist.begin(), InstructionsToHoist.end(), Pred);
}
- int NBBsOnAllPaths = MaxNumberOfBBSInPath;
+ int NumBBsOnAllPaths = MaxNumberOfBBSInPath;
SmallVecImplInsn::iterator II = InstructionsToHoist.begin();
SmallVecImplInsn::iterator Start = II;
@@ -546,10 +546,12 @@
BasicBlock *NewHoistBB;
Instruction *NewHoistPt;
- if (BB == HoistBB) {
+ if (BB == HoistBB) { // Both are in the same Basic Block.
NewHoistBB = HoistBB;
NewHoistPt = firstInBB(Insn, HoistPt) ? Insn : HoistPt;
} else {
+ // If the hoisting point contains one of the instructions,
+ // then hoist there, otherwise hoist before the terminator.
NewHoistBB = DT->findNearestCommonDominator(HoistBB, BB);
if (NewHoistBB == BB)
NewHoistPt = Insn;
@@ -564,7 +566,7 @@
WL.insert(BB);
if (K == InsKind::Scalar) {
- if (safeToHoistScalar(NewHoistBB, WL, NBBsOnAllPaths)) {
+ if (safeToHoistScalar(NewHoistBB, WL, NumBBsOnAllPaths)) {
// Extend HoistPt to NewHoistPt.
HoistPt = NewHoistPt;
HoistBB = NewHoistBB;
@@ -581,9 +583,9 @@
hoistingFromAllPaths(NewHoistBB, WL)) &&
// Also check that it is safe to move the load or store from HoistPt
// to NewHoistPt, and from Insn to NewHoistPt.
- safeToHoistLdSt(NewHoistPt, HoistPt, UD, K, NBBsOnAllPaths) &&
+ safeToHoistLdSt(NewHoistPt, HoistPt, UD, K, NumBBsOnAllPaths) &&
safeToHoistLdSt(NewHoistPt, Insn, MSSA->getMemoryAccess(Insn),
- K, NBBsOnAllPaths)) {
+ K, NumBBsOnAllPaths)) {
// Extend HoistPt to NewHoistPt.
HoistPt = NewHoistPt;
HoistBB = NewHoistBB;
@@ -602,7 +604,7 @@
UD = MSSA->getMemoryAccess(*Start);
HoistPt = Insn;
HoistBB = BB;
- NBBsOnAllPaths = MaxNumberOfBBSInPath;
+ NumBBsOnAllPaths = MaxNumberOfBBSInPath;
}
// Save the last partition.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27110.79247.patch
Type: text/x-patch
Size: 3376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161124/f7749f91/attachment.bin>
More information about the llvm-commits
mailing list