From 87b7f7e5e348e8c9586ec0b7ee16db3d8695e83e Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Mon, 6 Mar 2017 18:42:27 +0000 Subject: [PATCH] NewGVN: Only call isInstructionTrivially dead once per instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297046 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/NewGVN.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Transforms/Scalar/NewGVN.cpp b/lib/Transforms/Scalar/NewGVN.cpp index 68a492a0cc0..5738cd69951 100644 --- a/lib/Transforms/Scalar/NewGVN.cpp +++ b/lib/Transforms/Scalar/NewGVN.cpp @@ -1730,6 +1730,16 @@ std::pair NewGVN::assignDFSNumbers(BasicBlock *B, } for (auto &I : *B) { + // 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 value numbered. + if (isInstructionTriviallyDead(&I, TLI)) { + InstrDFS[&I] = 0; + DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n"); + markInstructionForDeletion(&I); + continue; + } + InstrDFS[&I] = End++; DFSToInstr.emplace_back(&I); } @@ -1800,15 +1810,6 @@ void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) { // congruence finding, and updating mappings. void NewGVN::valueNumberInstruction(Instruction *I) { DEBUG(dbgs() << "Processing instruction " << *I << "\n"); - // 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; - } if (!I->isTerminator()) { const Expression *Symbolized = nullptr; if (DebugCounter::shouldExecute(VNCounter)) { -- 2.50.1