[PATCH] D50323: [GVNHoist] Prune out useless CHI insertions
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 28 04:09:00 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340818: [GVNHoist] Prune out useless CHI insertions (authored by alelab01, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50323?vs=159256&id=162824#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50323
Files:
llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
Index: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
@@ -155,6 +155,7 @@
using CHIIt = SmallVectorImpl<CHIArg>::iterator;
using CHIArgs = iterator_range<CHIIt>;
+using CHICache = DenseMap<BasicBlock *, SmallPtrSet<Instruction *, 4>>;
using OutValuesType = DenseMap<BasicBlock *, SmallVector<CHIArg, 2>>;
using InValuesType =
DenseMap<BasicBlock *, SmallVector<std::pair<VNType, Instruction *>, 2>>;
@@ -766,6 +767,7 @@
ReverseIDFCalculator IDFs(*PDT);
OutValuesType OutValue;
InValuesType InValue;
+ CHICache CachedCHIs;
for (const auto &R : Ranks) {
const SmallVecInsn &V = Map.lookup(R);
if (V.size() < 2)
@@ -792,11 +794,12 @@
}
// Insert empty CHI node for this VN. This is used to factor out
// basic blocks where the ANTIC can potentially change.
- for (auto IDFB : IDFBlocks) { // TODO: Prune out useless CHI insertions.
+ for (auto IDFB : IDFBlocks) {
for (unsigned i = 0; i < V.size(); ++i) {
CHIArg C = {VN, nullptr, nullptr};
// Ignore spurious PDFs.
- if (DT->properlyDominates(IDFB, V[i]->getParent())) {
+ if (DT->properlyDominates(IDFB, V[i]->getParent()) &&
+ CachedCHIs[IDFB].insert(V[i]).second) {
OutValue[IDFB].push_back(C);
LLVM_DEBUG(dbgs() << "\nInsertion a CHI for BB: " << IDFB->getName()
<< ", for Insn: " << *V[i]);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50323.162824.patch
Type: text/x-patch
Size: 1610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180828/88d56e2c/attachment.bin>
More information about the llvm-commits
mailing list