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;
20
20
21
21
#define DEBUG_TYPE " vplan"
22
22
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
+
23
43
Type *VPTypeAnalysis::inferScalarTypeForRecipe (const VPBlendRecipe *R) {
24
44
Type *ResTy = inferScalarType (R->getIncomingValue (0 ));
25
45
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 {
58
58
VPTypeAnalysis (Type *CanonicalIVTy)
59
59
: CanonicalIVTy(CanonicalIVTy), Ctx(CanonicalIVTy->getContext ()) {}
60
60
61
+ VPTypeAnalysis (const VPlan &Plan);
62
+
61
63
// / Infer the type of \p V. Returns the scalar type of \p V.
62
64
Type *inferScalarType (const VPValue *V);
63
65
Original file line number Diff line number Diff line change @@ -455,8 +455,7 @@ bool VPlanVerifier::verify(const VPlan &Plan) {
455
455
bool llvm::verifyVPlanIsValid (const VPlan &Plan) {
456
456
VPDominatorTree VPDT;
457
457
VPDT.recalculate (const_cast <VPlan &>(Plan));
458
- VPTypeAnalysis TypeInfo (
459
- const_cast <VPlan &>(Plan).getCanonicalIV ()->getScalarType ());
458
+ VPTypeAnalysis TypeInfo (Plan);
460
459
VPlanVerifier Verifier (VPDT, TypeInfo);
461
460
return Verifier.verify (Plan);
462
461
}
You can’t perform that action at this time.
0 commit comments