aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Vectorize/LoopVectorize.h
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-01-04 17:48:25 +0000
committerNadav Rotem <nrotem@apple.com>2013-01-04 17:48:25 +0000
commite503319874f57ab4a0354521b03a71cf8e07b866 (patch)
tree6d6b818c02185f5523b3cde95373bb1beb36432a /lib/Transforms/Vectorize/LoopVectorize.h
parente12bf1875481b02d07b6ce9c153ec3410068e234 (diff)
LoopVectorizer:
1. Add code to estimate register pressure. 2. Add code to select the unroll factor based on register pressure. 3. Add bits to TargetTransformInfo to provide the number of registers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171469 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.h')
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.h b/lib/Transforms/Vectorize/LoopVectorize.h
index 68d7ee7046..2333b2bcf9 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.h
+++ b/lib/Transforms/Vectorize/LoopVectorize.h
@@ -68,6 +68,9 @@ const unsigned RuntimeMemoryCheckThreshold = 4;
/// This is the highest vector width that we try to generate.
const unsigned MaxVectorSize = 8;
+/// This is the highest Unroll Factor.
+const unsigned MaxUnrollSize = 4;
+
namespace llvm {
// Forward declarations.
@@ -473,17 +476,37 @@ private:
class LoopVectorizationCostModel {
public:
/// C'tor.
- LoopVectorizationCostModel(Loop *Lp, ScalarEvolution *Se,
+ LoopVectorizationCostModel(Loop *Lp, ScalarEvolution *Se, LoopInfo *Li,
LoopVectorizationLegality *Leg,
const VectorTargetTransformInfo *Vtti):
- TheLoop(Lp), SE(Se), Legal(Leg), VTTI(Vtti) { }
+ TheLoop(Lp), SE(Se), LI(Li), Legal(Leg), VTTI(Vtti) { }
- /// Returns the most profitable vectorization factor in powers of two.
+ /// \return The most profitable vectorization factor.
/// This method checks every power of two up to VF. If UserVF is not ZERO
/// then this vectorization factor will be selected if vectorization is
/// possible.
unsigned selectVectorizationFactor(bool OptForSize, unsigned UserVF);
+
+ /// \return The most profitable unroll factor.
+ /// If UserUF is non-zero then this method finds the best unroll-factor
+ /// based on register pressure and other parameters.
+ unsigned selectUnrollFactor(bool OptForSize, unsigned UserUF);
+
+ /// \brief A struct that represents some properties of the register usage
+ /// of a loop.
+ struct RegisterUsage {
+ /// Holds the number of loop invariant values that are used in the loop.
+ unsigned LoopInvariantRegs;
+ /// Holds the maximum number of concurrent live intervals in the loop.
+ unsigned MaxLocalUsers;
+ /// Holds the number of instructions in the loop.
+ unsigned NumInstructions;
+ };
+
+ /// \return information about the register usage of the loop.
+ RegisterUsage calculateRegisterUsage();
+
private:
/// Returns the expected execution cost. The unit of the cost does
/// not matter because we use the 'cost' units to compare different
@@ -504,7 +527,8 @@ private:
Loop *TheLoop;
/// Scev analysis.
ScalarEvolution *SE;
-
+ /// Loop Info analysis.
+ LoopInfo *LI;
/// Vectorization legality.
LoopVectorizationLegality *Legal;
/// Vector target information.