mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-10 21:04:56 +00:00
[LV] Pass legality analysis in vectorizer constructor (NFC)
The vectorizer already holds a pointer to the legality analysis in a member variable, so it makes sense that we would pass it in the constructor. llvm-svn: 283368
This commit is contained in:
parent
5fc2b1d2fe
commit
386546124f
@ -371,26 +371,23 @@ public:
|
|||||||
const TargetLibraryInfo *TLI,
|
const TargetLibraryInfo *TLI,
|
||||||
const TargetTransformInfo *TTI, AssumptionCache *AC,
|
const TargetTransformInfo *TTI, AssumptionCache *AC,
|
||||||
OptimizationRemarkEmitter *ORE, unsigned VecWidth,
|
OptimizationRemarkEmitter *ORE, unsigned VecWidth,
|
||||||
unsigned UnrollFactor)
|
unsigned UnrollFactor, LoopVectorizationLegality *LVL)
|
||||||
: OrigLoop(OrigLoop), PSE(PSE), LI(LI), DT(DT), TLI(TLI), TTI(TTI),
|
: OrigLoop(OrigLoop), PSE(PSE), LI(LI), DT(DT), TLI(TLI), TTI(TTI),
|
||||||
AC(AC), ORE(ORE), VF(VecWidth), UF(UnrollFactor),
|
AC(AC), ORE(ORE), VF(VecWidth), UF(UnrollFactor),
|
||||||
Builder(PSE.getSE()->getContext()), Induction(nullptr),
|
Builder(PSE.getSE()->getContext()), Induction(nullptr),
|
||||||
OldInduction(nullptr), VectorLoopValueMap(UnrollFactor, VecWidth),
|
OldInduction(nullptr), VectorLoopValueMap(UnrollFactor, VecWidth),
|
||||||
TripCount(nullptr), VectorTripCount(nullptr), Legal(nullptr),
|
TripCount(nullptr), VectorTripCount(nullptr), Legal(LVL),
|
||||||
AddedSafetyChecks(false) {}
|
AddedSafetyChecks(false) {}
|
||||||
|
|
||||||
// Perform the actual loop widening (vectorization).
|
// Perform the actual loop widening (vectorization).
|
||||||
// MinimumBitWidths maps scalar integer values to the smallest bitwidth they
|
// MinimumBitWidths maps scalar integer values to the smallest bitwidth they
|
||||||
// can be validly truncated to. The cost model has assumed this truncation
|
// can be validly truncated to. The cost model has assumed this truncation
|
||||||
// will happen when vectorizing.
|
// will happen when vectorizing.
|
||||||
void vectorize(LoopVectorizationLegality *L,
|
void vectorize(const MapVector<Instruction *, uint64_t> &MinimumBitWidths) {
|
||||||
const MapVector<Instruction *, uint64_t> &MinimumBitWidths) {
|
|
||||||
MinBWs = &MinimumBitWidths;
|
MinBWs = &MinimumBitWidths;
|
||||||
Legal = L;
|
|
||||||
// Create a new empty loop. Unlink the old loop and connect the new one.
|
// Create a new empty loop. Unlink the old loop and connect the new one.
|
||||||
createEmptyLoop();
|
createEmptyLoop();
|
||||||
// Widen each instruction in the old loop to a new one in the new loop.
|
// Widen each instruction in the old loop to a new one in the new loop.
|
||||||
// Use the Legality module to find the induction and reduction variables.
|
|
||||||
vectorizeLoop();
|
vectorizeLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,6 +762,7 @@ protected:
|
|||||||
/// to this type.
|
/// to this type.
|
||||||
const MapVector<Instruction *, uint64_t> *MinBWs;
|
const MapVector<Instruction *, uint64_t> *MinBWs;
|
||||||
|
|
||||||
|
/// The legality analysis.
|
||||||
LoopVectorizationLegality *Legal;
|
LoopVectorizationLegality *Legal;
|
||||||
|
|
||||||
// Record whether runtime checks are added.
|
// Record whether runtime checks are added.
|
||||||
@ -777,9 +775,10 @@ public:
|
|||||||
LoopInfo *LI, DominatorTree *DT,
|
LoopInfo *LI, DominatorTree *DT,
|
||||||
const TargetLibraryInfo *TLI,
|
const TargetLibraryInfo *TLI,
|
||||||
const TargetTransformInfo *TTI, AssumptionCache *AC,
|
const TargetTransformInfo *TTI, AssumptionCache *AC,
|
||||||
OptimizationRemarkEmitter *ORE, unsigned UnrollFactor)
|
OptimizationRemarkEmitter *ORE, unsigned UnrollFactor,
|
||||||
|
LoopVectorizationLegality *LVL)
|
||||||
: InnerLoopVectorizer(OrigLoop, PSE, LI, DT, TLI, TTI, AC, ORE, 1,
|
: InnerLoopVectorizer(OrigLoop, PSE, LI, DT, TLI, TTI, AC, ORE, 1,
|
||||||
UnrollFactor) {}
|
UnrollFactor, LVL) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void scalarizeInstruction(Instruction *Instr,
|
void scalarizeInstruction(Instruction *Instr,
|
||||||
@ -7163,8 +7162,8 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
|||||||
assert(IC > 1 && "interleave count should not be 1 or 0");
|
assert(IC > 1 && "interleave count should not be 1 or 0");
|
||||||
// If we decided that it is not legal to vectorize the loop, then
|
// If we decided that it is not legal to vectorize the loop, then
|
||||||
// interleave it.
|
// interleave it.
|
||||||
InnerLoopUnroller Unroller(L, PSE, LI, DT, TLI, TTI, AC, ORE, IC);
|
InnerLoopUnroller Unroller(L, PSE, LI, DT, TLI, TTI, AC, ORE, IC, &LVL);
|
||||||
Unroller.vectorize(&LVL, CM.MinBWs);
|
Unroller.vectorize(CM.MinBWs);
|
||||||
|
|
||||||
ORE->emit(OptimizationRemark(LV_NAME, "Interleaved", L->getStartLoc(),
|
ORE->emit(OptimizationRemark(LV_NAME, "Interleaved", L->getStartLoc(),
|
||||||
L->getHeader())
|
L->getHeader())
|
||||||
@ -7172,8 +7171,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
|||||||
<< NV("InterleaveCount", IC) << ")");
|
<< NV("InterleaveCount", IC) << ")");
|
||||||
} else {
|
} else {
|
||||||
// If we decided that it is *legal* to vectorize the loop, then do it.
|
// If we decided that it is *legal* to vectorize the loop, then do it.
|
||||||
InnerLoopVectorizer LB(L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width, IC);
|
InnerLoopVectorizer LB(L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width, IC,
|
||||||
LB.vectorize(&LVL, CM.MinBWs);
|
&LVL);
|
||||||
|
LB.vectorize(CM.MinBWs);
|
||||||
++LoopsVectorized;
|
++LoopsVectorized;
|
||||||
|
|
||||||
// Add metadata to disable runtime unrolling a scalar loop when there are
|
// Add metadata to disable runtime unrolling a scalar loop when there are
|
||||||
|
Loading…
Reference in New Issue
Block a user