[PATCH] D28930: [NewGVN] Optimize processing as instructions don't get more trivially dead over time
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 15:40:33 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292676: [NewGVN] Optimize processing for instructions found trivially dead. (authored by davide).
Changed prior to commit:
https://reviews.llvm.org/D28930?vs=85065&id=85207#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28930
Files:
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
Index: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
@@ -242,7 +242,12 @@
#endif
// DFS info.
+ // This contains a mapping from Instructions to DFS numbers.
+ // The numbering starts at 1. An instruction with DFS number zero
+ // means that the instruction is dead.
DenseMap<const Value *, unsigned> InstrDFS;
+
+ // This contains the mapping DFS numbers to instructions.
SmallVector<Value *, 32> DFSToInstr;
// Deletion info.
@@ -1504,7 +1509,12 @@
// congruence finding, and updating mappings.
void NewGVN::valueNumberInstruction(Instruction *I) {
DEBUG(dbgs() << "Processing instruction " << *I << "\n");
- if (isInstructionTriviallyDead(I, TLI)) {
+
+ // There's no need to call isInstructionTriviallyDead more than once on
+ // an instruction. Therefore, once we know that an instruction is dead
+ // we change its DFS number so that it doesn't get numbered again.
+ if (InstrDFS[I] != 0 && isInstructionTriviallyDead(I, TLI)) {
+ InstrDFS[I] = 0;
DEBUG(dbgs() << "Skipping unused instruction\n");
markInstructionForDeletion(I);
return;
@@ -1705,8 +1715,14 @@
// Walk through all the instructions in all the blocks in RPO.
for (int InstrNum = TouchedInstructions.find_first(); InstrNum != -1;
InstrNum = TouchedInstructions.find_next(InstrNum)) {
- assert(InstrNum != 0 && "Bit 0 should never be set, something touched an "
- "instruction not in the lookup table");
+
+ // This instruction was found to be dead. We don't bother looking
+ // at it again.
+ if (InstrNum == 0) {
+ TouchedInstructions.reset(InstrNum);
+ continue;
+ }
+
Value *V = DFSToInstr[InstrNum];
BasicBlock *CurrBlock = nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28930.85207.patch
Type: text/x-patch
Size: 1920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170120/7a72d1ea/attachment.bin>
More information about the llvm-commits
mailing list