[PATCH] D35291: [CGP] Cleanup - remove redundant code in OptimizeMemoryInst. NFC
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 17 22:17:18 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308265: [CGP] Cleanup - remove redundant code in OptimizeMemoryInst. NFC (authored by skatkov).
Changed prior to commit:
https://reviews.llvm.org/D35291?vs=106141&id=107019#toc
Repository:
rL LLVM
https://reviews.llvm.org/D35291
Files:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
Index: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
@@ -4267,9 +4267,7 @@
// Use a worklist to iteratively look through PHI nodes, and ensure that
// the addressing mode obtained from the non-PHI roots of the graph
// are equivalent.
- Value *Consensus = nullptr;
- unsigned NumUsesConsensus = 0;
- bool IsNumUsesConsensusValid = false;
+ bool AddrModeFound = false;
bool PhiSeen = false;
SmallVector<Instruction*, 16> AddrModeInsts;
ExtAddrMode AddrMode;
@@ -4282,7 +4280,7 @@
// Break use-def graph loops.
if (!Visited.insert(V).second) {
- Consensus = nullptr;
+ AddrModeFound = false;
break;
}
@@ -4297,47 +4295,26 @@
// For non-PHIs, determine the addressing mode being computed. Note that
// the result may differ depending on what other uses our candidate
// addressing instructions might have.
- SmallVector<Instruction*, 16> NewAddrModeInsts;
+ AddrModeInsts.clear();
ExtAddrMode NewAddrMode = AddressingModeMatcher::Match(
- V, AccessTy, AddrSpace, MemoryInst, NewAddrModeInsts, *TLI, *TRI,
- InsertedInsts, PromotedInsts, TPT);
+ V, AccessTy, AddrSpace, MemoryInst, AddrModeInsts, *TLI, *TRI,
+ InsertedInsts, PromotedInsts, TPT);
- // This check is broken into two cases with very similar code to avoid using
- // getNumUses() as much as possible. Some values have a lot of uses, so
- // calling getNumUses() unconditionally caused a significant compile-time
- // regression.
- if (!Consensus) {
- Consensus = V;
+ if (!AddrModeFound) {
+ AddrModeFound = true;
AddrMode = NewAddrMode;
- AddrModeInsts = NewAddrModeInsts;
- continue;
- } else if (NewAddrMode == AddrMode) {
- if (!IsNumUsesConsensusValid) {
- NumUsesConsensus = Consensus->getNumUses();
- IsNumUsesConsensusValid = true;
- }
-
- // Ensure that the obtained addressing mode is equivalent to that obtained
- // for all other roots of the PHI traversal. Also, when choosing one
- // such root as representative, select the one with the most uses in order
- // to keep the cost modeling heuristics in AddressingModeMatcher
- // applicable.
- unsigned NumUses = V->getNumUses();
- if (NumUses > NumUsesConsensus) {
- Consensus = V;
- NumUsesConsensus = NumUses;
- AddrModeInsts = NewAddrModeInsts;
- }
continue;
}
+ if (NewAddrMode == AddrMode)
+ continue;
- Consensus = nullptr;
+ AddrModeFound = false;
break;
}
// If the addressing mode couldn't be determined, or if multiple different
// ones were determined, bail out now.
- if (!Consensus) {
+ if (!AddrModeFound) {
TPT.rollback(LastKnownGood);
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35291.107019.patch
Type: text/x-patch
Size: 2951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170718/7aefb620/attachment.bin>
More information about the llvm-commits
mailing list