@@ -221,7 +221,7 @@ VPTransformState::VPTransformState(const TargetTransformInfo *TTI,
221221 Loop *CurrentParentLoop, Type *CanonicalIVTy)
222222 : TTI(TTI), VF(VF), CFG(DT), LI(LI), Builder(Builder), ILV(ILV), Plan(Plan),
223223 CurrentParentLoop(CurrentParentLoop), LVer(nullptr ),
224- TypeAnalysis(CanonicalIVTy) {}
224+ TypeAnalysis(CanonicalIVTy-> getContext () ) {}
225225
226226Value *VPTransformState::get (const VPValue *Def, const VPLane &Lane) {
227227 if (Def->isLiveIn ())
@@ -847,7 +847,8 @@ void VPRegionBlock::print(raw_ostream &O, const Twine &Indent,
847847}
848848#endif
849849
850- VPlan::VPlan (Loop *L) {
850+ VPlan::VPlan (Loop *L, Type *InductionTy)
851+ : VectorTripCount(InductionTy), VF(InductionTy), VFxUF(InductionTy) {
851852 setEntry (createVPIRBasicBlock (L->getLoopPreheader ()));
852853 ScalarHeader = createVPIRBasicBlock (L->getHeader ());
853854
@@ -858,7 +859,7 @@ VPlan::VPlan(Loop *L) {
858859}
859860
860861VPlan::~VPlan () {
861- VPValue DummyValue;
862+ VPValue DummyValue ((Type *) nullptr ) ;
862863
863864 for (auto *VPB : CreatedBlocks) {
864865 if (auto *VPBB = dyn_cast<VPBasicBlock>(VPB)) {
@@ -888,10 +889,10 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
888889 IRBuilder<> Builder (State.CFG .PrevBB ->getTerminator ());
889890 auto *TCMO = Builder.CreateSub (TripCountV, ConstantInt::get (TCTy, 1 ),
890891 " trip.count.minus.1" );
891- BackedgeTakenCount->setUnderlyingValue ( TCMO);
892+ BackedgeTakenCount->replaceAllUsesWith ( getOrAddLiveIn ( TCMO) );
892893 }
893894
894- VectorTripCount.setUnderlyingValue ( VectorTripCountV);
895+ VectorTripCount.replaceAllUsesWith ( getOrAddLiveIn ( VectorTripCountV) );
895896
896897 IRBuilder<> Builder (State.CFG .PrevBB ->getTerminator ());
897898 // FIXME: Model VF * UF computation completely in VPlan.
@@ -900,12 +901,13 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
900901 unsigned UF = getUF ();
901902 if (VF.getNumUsers ()) {
902903 Value *RuntimeVF = getRuntimeVF (Builder, TCTy, State.VF );
903- VF.setUnderlyingValue ( RuntimeVF);
904- VFxUF.setUnderlyingValue (
904+ VF.replaceAllUsesWith ( getOrAddLiveIn ( RuntimeVF) );
905+ VFxUF.replaceAllUsesWith ( getOrAddLiveIn (
905906 UF > 1 ? Builder.CreateMul (RuntimeVF, ConstantInt::get (TCTy, UF))
906- : RuntimeVF);
907+ : RuntimeVF)) ;
907908 } else {
908- VFxUF.setUnderlyingValue (createStepForVF (Builder, TCTy, State.VF , UF));
909+ VFxUF.replaceAllUsesWith (
910+ getOrAddLiveIn (createStepForVF (Builder, TCTy, State.VF , UF)));
909911 }
910912}
911913
@@ -1166,7 +1168,8 @@ VPlan *VPlan::duplicate() {
11661168 return VPIRBB && VPIRBB->getIRBasicBlock () == ScalarHeaderIRBB;
11671169 }));
11681170 // Create VPlan, clone live-ins and remap operands in the cloned blocks.
1169- auto *NewPlan = new VPlan (cast<VPBasicBlock>(NewEntry), NewScalarHeader);
1171+ auto *NewPlan = new VPlan (cast<VPBasicBlock>(NewEntry), NewScalarHeader,
1172+ getCanonicalIV ()->getScalarType ());
11701173 DenseMap<VPValue *, VPValue *> Old2NewVPValues;
11711174 for (VPValue *OldLiveIn : getLiveIns ()) {
11721175 Old2NewVPValues[OldLiveIn] =
@@ -1176,7 +1179,7 @@ VPlan *VPlan::duplicate() {
11761179 Old2NewVPValues[&VF] = &NewPlan->VF ;
11771180 Old2NewVPValues[&VFxUF] = &NewPlan->VFxUF ;
11781181 if (BackedgeTakenCount) {
1179- NewPlan->BackedgeTakenCount = new VPValue ();
1182+ NewPlan->BackedgeTakenCount = new VPValue ((Type *) nullptr );
11801183 Old2NewVPValues[BackedgeTakenCount] = NewPlan->BackedgeTakenCount ;
11811184 }
11821185 assert (TripCount && " trip count must be set" );
@@ -1379,6 +1382,11 @@ static bool isDefinedInsideLoopRegions(const VPValue *VPV) {
13791382 DefR->getParent ()->getEnclosingLoopRegion ());
13801383}
13811384
1385+ Type *VPValue::getType () const {
1386+ assert (isLiveIn ());
1387+ return SubclassID == VPSymbolicValueSC ? Ty : getUnderlyingValue ()->getType ();
1388+ }
1389+
13821390bool VPValue::isDefinedOutsideLoopRegions () const {
13831391 return !isDefinedInsideLoopRegions (this );
13841392}
0 commit comments