class BoUpSLP::LookAheadHeuristics
Declaration
class BoUpSLP::LookAheadHeuristics { /* full declaration omitted */ };
Description
A helper class used for scoring candidates for two consecutive lanes.
Declared at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1054
Member Variables
- private const llvm::DataLayout& DL
- private llvm::ScalarEvolution& SE
- private const llvm::slpvectorizer::BoUpSLP& R
- private int NumLanes
- private int MaxLevel
- public static const int ScoreConsecutiveLoads = 4
- Loads from consecutive memory addresses, e.g. load(A[i]), load(A[i+1]).
- public static const int ScoreSplatLoads = 3
- The same load multiple times. This should have a better score than `ScoreSplat` because it in x86 for a 2-lane vector we can represent it with `movddup (%reg), xmm0` which has a throughput of 0.5 versus 0.5 for a vector load and 1.0 for a broadcast.
- public static const int ScoreReversedLoads = 3
- Loads from reversed memory addresses, e.g. load(A[i+1]), load(A[i]).
- public static const int ScoreConsecutiveExtracts = 4
- ExtractElementInst from same vector and consecutive indexes.
- public static const int ScoreReversedExtracts = 3
- ExtractElementInst from same vector and reversed indices.
- public static const int ScoreConstants = 2
- Constants.
- public static const int ScoreSameOpcode = 2
- Instructions with the same opcode.
- public static const int ScoreAltOpcodes = 1
- Instructions with alt opcodes (e.g, add + sub).
- public static const int ScoreSplat = 1
- Identical instructions (a.k.a. splat or broadcast).
- public static const int ScoreUndef = 1
- Matching with an undef is preferable to failing.
- public static const int ScoreFail = 0
- Score for failing to find a decent match.
- public static const int ScoreAllUserVectorized = 1
- Score if all users are vectorized.
Method Overview
- public LookAheadHeuristics(const llvm::DataLayout & DL, llvm::ScalarEvolution & SE, const llvm::slpvectorizer::BoUpSLP & R, int NumLanes, int MaxLevel)
- public int getScoreAtLevelRec(llvm::Value * LHS, llvm::Value * RHS, llvm::Instruction * U1, llvm::Instruction * U2, int CurrLevel, ArrayRef<llvm::Value *> MainAltOps) const
- public int getShallowScore(llvm::Value * V1, llvm::Value * V2, llvm::Instruction * U1, llvm::Instruction * U2, ArrayRef<llvm::Value *> MainAltOps) const
Methods
¶LookAheadHeuristics(
const llvm::DataLayout& DL,
llvm::ScalarEvolution& SE,
const llvm::slpvectorizer::BoUpSLP& R,
int NumLanes,
int MaxLevel)
LookAheadHeuristics(
const llvm::DataLayout& DL,
llvm::ScalarEvolution& SE,
const llvm::slpvectorizer::BoUpSLP& R,
int NumLanes,
int MaxLevel)
Declared at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1062
Parameters
- const llvm::DataLayout& DL
- llvm::ScalarEvolution& SE
- const llvm::slpvectorizer::BoUpSLP& R
- int NumLanes
- int MaxLevel
¶int getScoreAtLevelRec(
llvm::Value* LHS,
llvm::Value* RHS,
llvm::Instruction* U1,
llvm::Instruction* U2,
int CurrLevel,
ArrayRef<llvm::Value*> MainAltOps) const
int getScoreAtLevelRec(
llvm::Value* LHS,
llvm::Value* RHS,
llvm::Instruction* U1,
llvm::Instruction* U2,
int CurrLevel,
ArrayRef<llvm::Value*> MainAltOps) const
Description
Go through the operands of \p LHS and \p RHS recursively until MaxLevel, and return the cummulative score. \p U1 and \p U2 are the users of \p LHS and \p RHS (that is \p LHS and \p RHS are operands of \p U1 and \p U2), except at the beginning of the recursion where these are set to nullptr. For example: The getScoreAtLevelRec(G1, G2) function will try to match the nodes at each level recursively, accumulating the score. It starts from matching the additions at level 0, then moves on to the loads (level 1). The score of G1 and G2 is higher than G1 and G3, because {A[0],A[1]} and {B[0],B[1]} match with LookAheadHeuristics::ScoreConsecutiveLoads, while {A[0],C[0]} has a score of LookAheadHeuristics::ScoreFail. Please note that the order of the operands does not matter, as we evaluate the score of all profitable combinations of operands. In other words the score of G1 and G4 is the same as G1 and G2. This heuristic is based on ideas described in: Look-ahead SLP: Auto-vectorization in the presence of commutative operations, CGO 2018 by Vasileios Porpodas, Rodrigo C. O. Rocha, Luís F. W. Góes
Declared at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1254
Parameters
- llvm::Value* LHS
- llvm::Value* RHS
- llvm::Instruction* U1
- llvm::Instruction* U2
- int CurrLevel
- ArrayRef<llvm::Value*> MainAltOps
¶int getShallowScore(
llvm::Value* V1,
llvm::Value* V2,
llvm::Instruction* U1,
llvm::Instruction* U2,
ArrayRef<llvm::Value*> MainAltOps) const
int getShallowScore(
llvm::Value* V1,
llvm::Value* V2,
llvm::Instruction* U1,
llvm::Instruction* U2,
ArrayRef<llvm::Value*> MainAltOps) const
Declared at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1109
Parameters
- llvm::Value* V1
- llvm::Value* V2
- llvm::Instruction* U1
- llvm::Instruction* U2
- ArrayRef<llvm::Value*> MainAltOps
Returns
the score of placing \p V1 and \p V2 in consecutive lanes.\p U1 and \p U2 are the users of \p V1 and \p V2. Also, checks if \p V1 and \p V2 are compatible with instructions in \p MainAltOps.