From 83474ee594b5b14e9071564814a90571805cc433 Mon Sep 17 00:00:00 2001 From: Preston Gurd Date: Fri, 1 Feb 2013 20:41:27 +0000 Subject: [PATCH] This patch aims to improve compile time performance by increasing the SCEV vector size in LoopStrengthReduce. It is observed that the BaseRegs vector size is 4 in most cases, and elements are frequently copied when it is initialized as SmallVector BaseRegs. Our benchmark results show that the compilation time performance improved by ~0.5%. Patch by Wan Xiaofei. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174219 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 87e34473fca..923707737ad 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -237,7 +237,7 @@ struct Formula { /// BaseRegs - The list of "base" registers for this use. When this is /// non-empty, - SmallVector BaseRegs; + SmallVector BaseRegs; /// ScaledReg - The 'scaled' register for this use. This should be non-null /// when Scale is not zero. @@ -1087,19 +1087,19 @@ namespace { /// UniquifierDenseMapInfo - A DenseMapInfo implementation for holding /// DenseMaps and DenseSets of sorted SmallVectors of const SCEV*. struct UniquifierDenseMapInfo { - static SmallVector getEmptyKey() { - SmallVector V; + static SmallVector getEmptyKey() { + SmallVector V; V.push_back(reinterpret_cast(-1)); return V; } - static SmallVector getTombstoneKey() { - SmallVector V; + static SmallVector getTombstoneKey() { + SmallVector V; V.push_back(reinterpret_cast(-2)); return V; } - static unsigned getHashValue(const SmallVector &V) { + static unsigned getHashValue(const SmallVector &V) { unsigned Result = 0; for (SmallVectorImpl::const_iterator I = V.begin(), E = V.end(); I != E; ++I) @@ -1107,8 +1107,8 @@ struct UniquifierDenseMapInfo { return Result; } - static bool isEqual(const SmallVector &LHS, - const SmallVector &RHS) { + static bool isEqual(const SmallVector &LHS, + const SmallVector &RHS) { return LHS == RHS; } }; @@ -1119,7 +1119,7 @@ struct UniquifierDenseMapInfo { /// the user itself, and information about how the use may be satisfied. /// TODO: Represent multiple users of the same expression in common? class LSRUse { - DenseSet, UniquifierDenseMapInfo> Uniquifier; + DenseSet, UniquifierDenseMapInfo> Uniquifier; public: /// KindType - An enum for a kind of use, indicating what types of @@ -1178,7 +1178,7 @@ public: /// HasFormula - Test whether this use as a formula which has the same /// registers as the given formula. bool LSRUse::HasFormulaWithSameRegs(const Formula &F) const { - SmallVector Key = F.BaseRegs; + SmallVector Key = F.BaseRegs; if (F.ScaledReg) Key.push_back(F.ScaledReg); // Unstable sort by host order ok, because this is only used for uniquifying. std::sort(Key.begin(), Key.end()); @@ -1188,7 +1188,7 @@ bool LSRUse::HasFormulaWithSameRegs(const Formula &F) const { /// InsertFormula - If the given formula has not yet been inserted, add it to /// the list, and return true. Return false otherwise. bool LSRUse::InsertFormula(const Formula &F) { - SmallVector Key = F.BaseRegs; + SmallVector Key = F.BaseRegs; if (F.ScaledReg) Key.push_back(F.ScaledReg); // Unstable sort by host order ok, because this is only used for uniquifying. std::sort(Key.begin(), Key.end()); @@ -3656,7 +3656,7 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() { // Collect the best formula for each unique set of shared registers. This // is reset for each use. - typedef DenseMap, size_t, UniquifierDenseMapInfo> + typedef DenseMap, size_t, UniquifierDenseMapInfo> BestFormulaeTy; BestFormulaeTy BestFormulae; @@ -3691,7 +3691,7 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() { dbgs() << "\n"); } else { - SmallVector Key; + SmallVector Key; for (SmallVectorImpl::const_iterator J = F.BaseRegs.begin(), JE = F.BaseRegs.end(); J != JE; ++J) { const SCEV *Reg = *J;