From 415f41258fa99d829c35408e2a276cf5f63705d2 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 13 Feb 2015 02:17:39 +0000 Subject: [PATCH] [unroll] Avoid the "Insn" abbreviation of Instruction. This is quite hard to type and read for me, and is inconsistent with the other abbreviation in the base class "Inst". For most of these (where they are used widely) I prefer just spelling it out as Instruction. I've changed two of the short-lived variables to use "Inst" to match the base class. llvm-svn: 229028 --- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index 5586032b742b..aabdf065a633 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -333,7 +333,7 @@ class UnrollAnalyzer : public InstVisitor { DenseMap SimplifiedValues; DenseMap LoadBaseAddresses; - SmallPtrSet CountedInsns; + SmallPtrSet CountedInstructions; /// \brief Count the number of optimized instructions. unsigned NumberOfOptimizedInstructions; @@ -362,7 +362,7 @@ class UnrollAnalyzer : public InstVisitor { else SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS); - if (SimpleV && CountedInsns.insert(&I).second) + if (SimpleV && CountedInstructions.insert(&I).second) NumberOfOptimizedInstructions += TTI.getUserCost(&I); if (Constant *C = dyn_cast_or_null(SimpleV)) { @@ -453,18 +453,18 @@ public: // Given a list of loads that could be constant-folded (LoadBaseAddresses), // estimate number of optimized instructions after substituting the concrete // values for the given Iteration. - // Fill in SimplifiedInsns map for future use in DCE-estimation. - unsigned estimateNumberOfSimplifiedInsns(unsigned Iteration) { + // Fill in SimplifiedValues map for future use in DCE-estimation. + unsigned estimateNumberOfSimplifiedInstructions(unsigned Iteration) { SmallVector Worklist; SimplifiedValues.clear(); - CountedInsns.clear(); + CountedInstructions.clear(); NumberOfOptimizedInstructions = 0; // We start by adding all loads to the worklist. for (auto LoadDescr : LoadBaseAddresses) { LoadInst *LI = LoadDescr.first; SimplifiedValues[LI] = computeLoadValue(LI, Iteration); - if (CountedInsns.insert(LI).second) + if (CountedInstructions.insert(LI).second) NumberOfOptimizedInstructions += TTI.getUserCost(LI); for (auto U : LI->users()) { @@ -498,24 +498,24 @@ public: // Given a list of potentially simplifed instructions, estimate number of // instructions that would become dead if we do perform the simplification. - unsigned estimateNumberOfDeadInsns() { + unsigned estimateNumberOfDeadInstructions() { NumberOfOptimizedInstructions = 0; SmallVector Worklist; SmallPtrSet DeadInstructions; // Start by initializing worklist with simplified instructions. - for (auto Folded : SimplifiedValues) { - if (auto FoldedInsn = dyn_cast(Folded.first)) { - Worklist.push_back(FoldedInsn); - DeadInstructions.insert(FoldedInsn); + for (auto Folded : SimplifiedValues) + if (auto FoldedInst = dyn_cast(Folded.first)) { + Worklist.push_back(FoldedInst); + DeadInstructions.insert(FoldedInst); } - } + // If a definition of an insn is only used by simplified or dead // instructions, it's also dead. Check defs of all instructions from the // worklist. while (!Worklist.empty()) { - Instruction *FoldedInsn = Worklist.pop_back_val(); - for (Value *Op : FoldedInsn->operands()) { + Instruction *FoldedInst = Worklist.pop_back_val(); + for (Value *Op : FoldedInst->operands()) { if (auto I = dyn_cast(Op)) { if (!L->contains(I)) continue; @@ -566,8 +566,9 @@ approximateNumberOfOptimizedInstructions(const Loop *L, ScalarEvolution &SE, std::min(UnrollMaxIterationsCountToAnalyze, TripCount); unsigned NumberOfOptimizedInstructions = 0; for (unsigned i = 0; i < IterationsNumberForEstimate; ++i) { - NumberOfOptimizedInstructions += UA.estimateNumberOfSimplifiedInsns(i); - NumberOfOptimizedInstructions += UA.estimateNumberOfDeadInsns(); + NumberOfOptimizedInstructions += + UA.estimateNumberOfSimplifiedInstructions(i); + NumberOfOptimizedInstructions += UA.estimateNumberOfDeadInstructions(); } NumberOfOptimizedInstructions *= TripCount / IterationsNumberForEstimate;