Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
// S. Maleki, Y. Gao, M. Garzaran, T. Wong and D. Padua. An Evaluation of | // S. Maleki, Y. Gao, M. Garzaran, T. Wong and D. Padua. An Evaluation of | ||||
// Vectorizing Compilers. | // Vectorizing Compilers. | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "llvm/Transforms/Vectorize/LoopVectorize.h" | #include "llvm/Transforms/Vectorize/LoopVectorize.h" | ||||
#include "LoopVectorizationPlanner.h" | #include "LoopVectorizationPlanner.h" | ||||
#include "VPRecipeBuilder.h" | #include "VPRecipeBuilder.h" | ||||
#include "VPlan.h" | |||||
#include "VPlanHCFGBuilder.h" | #include "VPlanHCFGBuilder.h" | ||||
#include "VPlanHCFGTransforms.h" | #include "VPlanHCFGTransforms.h" | ||||
#include "VPlanPredicator.h" | #include "VPlanPredicator.h" | ||||
#include "llvm/ADT/APInt.h" | #include "llvm/ADT/APInt.h" | ||||
#include "llvm/ADT/ArrayRef.h" | #include "llvm/ADT/ArrayRef.h" | ||||
#include "llvm/ADT/DenseMap.h" | #include "llvm/ADT/DenseMap.h" | ||||
#include "llvm/ADT/DenseMapInfo.h" | #include "llvm/ADT/DenseMapInfo.h" | ||||
#include "llvm/ADT/Hashing.h" | #include "llvm/ADT/Hashing.h" | ||||
▲ Show 20 Lines • Show All 6,757 Lines • ▼ Show 20 Lines | void LoopVectorizationPlanner::buildVPlansWithVPRecipes(unsigned MinVF, | ||||
for (unsigned VF = MinVF; VF < MaxVF + 1;) { | for (unsigned VF = MinVF; VF < MaxVF + 1;) { | ||||
VFRange SubRange = {VF, MaxVF + 1}; | VFRange SubRange = {VF, MaxVF + 1}; | ||||
VPlans.push_back( | VPlans.push_back( | ||||
buildVPlanWithVPRecipes(SubRange, NeedDef, DeadInstructions)); | buildVPlanWithVPRecipes(SubRange, NeedDef, DeadInstructions)); | ||||
VF = SubRange.End; | VF = SubRange.End; | ||||
} | } | ||||
} | } | ||||
LoopVectorizationPlanner::VPlanPtr | VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes( | ||||
LoopVectorizationPlanner::buildVPlanWithVPRecipes( | |||||
VFRange &Range, SmallPtrSetImpl<Value *> &NeedDef, | VFRange &Range, SmallPtrSetImpl<Value *> &NeedDef, | ||||
SmallPtrSetImpl<Instruction *> &DeadInstructions) { | SmallPtrSetImpl<Instruction *> &DeadInstructions) { | ||||
// Hold a mapping from predicated instructions to their recipes, in order to | // Hold a mapping from predicated instructions to their recipes, in order to | ||||
// fix their AlsoPack behavior if a user is determined to replicate and use a | // fix their AlsoPack behavior if a user is determined to replicate and use a | ||||
// scalar instead of vector value. | // scalar instead of vector value. | ||||
DenseMap<Instruction *, VPReplicateRecipe *> PredInst2Recipe; | DenseMap<Instruction *, VPReplicateRecipe *> PredInst2Recipe; | ||||
DenseMap<Instruction *, Instruction *> &SinkAfter = Legal->getSinkAfter(); | DenseMap<Instruction *, Instruction *> &SinkAfter = Legal->getSinkAfter(); | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes( | ||||
} | } | ||||
RSO << "},UF>=1"; | RSO << "},UF>=1"; | ||||
RSO.flush(); | RSO.flush(); | ||||
Plan->setName(PlanName); | Plan->setName(PlanName); | ||||
return Plan; | return Plan; | ||||
} | } | ||||
LoopVectorizationPlanner::VPlanPtr | VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) { | ||||
LoopVectorizationPlanner::buildVPlan(VFRange &Range) { | |||||
// Outer loop handling: They may require CFG and instruction level | // Outer loop handling: They may require CFG and instruction level | ||||
// transformations before even evaluating whether vectorization is profitable. | // transformations before even evaluating whether vectorization is profitable. | ||||
// Since we cannot modify the incoming IR, we need to build VPlan upfront in | // Since we cannot modify the incoming IR, we need to build VPlan upfront in | ||||
// the vectorization pipeline. | // the vectorization pipeline. | ||||
assert(!OrigLoop->empty()); | assert(!OrigLoop->empty()); | ||||
assert(EnableVPlanNativePath && "VPlan-native path is not enabled."); | assert(EnableVPlanNativePath && "VPlan-native path is not enabled."); | ||||
// Create new empty VPlan | // Create new empty VPlan | ||||
▲ Show 20 Lines • Show All 699 Lines • Show Last 20 Lines |