From c6ee1a00f8b4d1ca7ec436255f06a49be12acf84 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 22 Apr 2016 18:47:21 +0000 Subject: [PATCH] [EarlyCSE/CVP] Add stats for CVPs and make sure to account for any Changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267187 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/EarlyCSE.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Scalar/EarlyCSE.cpp b/lib/Transforms/Scalar/EarlyCSE.cpp index 949300b94a7..f490c2b6653 100644 --- a/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/lib/Transforms/Scalar/EarlyCSE.cpp @@ -40,6 +40,7 @@ using namespace llvm::PatternMatch; STATISTIC(NumSimplify, "Number of instructions simplified or DCE'd"); STATISTIC(NumCSE, "Number of instructions CSE'd"); +STATISTIC(NumCSECVP, "Number of compare instructions CVP'd"); STATISTIC(NumCSELoad, "Number of load instructions CSE'd"); STATISTIC(NumCSECall, "Number of call instructions CSE'd"); STATISTIC(NumDSE, "Number of trivial dead stores removed"); @@ -482,6 +483,7 @@ private: } bool EarlyCSE::processNode(DomTreeNode *Node) { + bool Changed = false; BasicBlock *BB = Node->getBlock(); // If this block has a single predecessor, then the predecessor is the parent @@ -512,9 +514,13 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { DEBUG(dbgs() << "EarlyCSE CVP: Add conditional value for '" << CondInst->getName() << "' as " << *ConditionalConstant << " in " << BB->getName() << "\n"); - // Replace all dominated uses with the known value - replaceDominatedUsesWith(CondInst, ConditionalConstant, DT, - BasicBlockEdge(Pred, BB)); + // Replace all dominated uses with the known value. + if (unsigned Count = + replaceDominatedUsesWith(CondInst, ConditionalConstant, DT, + BasicBlockEdge(Pred, BB))) { + Changed = true; + NumCSECVP = NumCSECVP + Count; + } } /// LastStore - Keep track of the last non-volatile store that we saw... for @@ -523,7 +529,6 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { /// stores which can occur in bitfield code among other things. Instruction *LastStore = nullptr; - bool Changed = false; const DataLayout &DL = BB->getModule()->getDataLayout(); // See if any instructions in the block can be eliminated. If so, do it. If -- 2.11.0