File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,26 @@ using namespace llvm;
2020
2121#define DEBUG_TYPE " vplan"
2222
23+ VPTypeAnalysis::VPTypeAnalysis (const VPlan &Plan)
24+ : Ctx(Plan.getScalarHeader()->getIRBasicBlock()->getContext()) {
25+ if (auto LoopRegion = Plan.getVectorLoopRegion ()) {
26+ if (const auto *CanIV = dyn_cast<VPCanonicalIVPHIRecipe>(
27+ &LoopRegion->getEntryBasicBlock ()->front ())) {
28+ CanonicalIVTy = CanIV->getScalarType ();
29+ return ;
30+ }
31+ }
32+
33+ // If there's no canonical IV, retrieve the type from the trip count
34+ // expression.
35+ auto *TC = Plan.getTripCount ();
36+ if (TC->isLiveIn ()) {
37+ CanonicalIVTy = TC->getLiveInIRValue ()->getType ();
38+ return ;
39+ }
40+ CanonicalIVTy = cast<VPExpandSCEVRecipe>(TC)->getSCEV ()->getType ();
41+ }
42+
2343Type *VPTypeAnalysis::inferScalarTypeForRecipe (const VPBlendRecipe *R) {
2444 Type *ResTy = inferScalarType (R->getIncomingValue (0 ));
2545 for (unsigned I = 1 , E = R->getNumIncomingValues (); I != E; ++I) {
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ class VPTypeAnalysis {
5858 VPTypeAnalysis (Type *CanonicalIVTy)
5959 : CanonicalIVTy(CanonicalIVTy), Ctx(CanonicalIVTy->getContext ()) {}
6060
61+ VPTypeAnalysis (const VPlan &Plan);
62+
6163 // / Infer the type of \p V. Returns the scalar type of \p V.
6264 Type *inferScalarType (const VPValue *V);
6365
Original file line number Diff line number Diff line change @@ -455,8 +455,7 @@ bool VPlanVerifier::verify(const VPlan &Plan) {
455455bool llvm::verifyVPlanIsValid (const VPlan &Plan) {
456456 VPDominatorTree VPDT;
457457 VPDT.recalculate (const_cast <VPlan &>(Plan));
458- VPTypeAnalysis TypeInfo (
459- const_cast <VPlan &>(Plan).getCanonicalIV ()->getScalarType ());
458+ VPTypeAnalysis TypeInfo (Plan);
460459 VPlanVerifier Verifier (VPDT, TypeInfo);
461460 return Verifier.verify (Plan);
462461}
You can’t perform that action at this time.
0 commit comments