File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -9682,12 +9682,20 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9682
9682
VPBasicBlock *LatchVPBB = VectorLoopRegion->getExitingBasicBlock ();
9683
9683
Builder.setInsertPoint (&*LatchVPBB->begin ());
9684
9684
VPBasicBlock::iterator IP = MiddleVPBB->getFirstNonPhi ();
9685
- for (VPRecipeBase &R :
9686
- Plan->getVectorLoopRegion ()->getEntryBasicBlock ()->phis ()) {
9685
+ for (VPRecipeBase &R : make_early_inc_range (
9686
+ Plan->getVectorLoopRegion ()->getEntryBasicBlock ()->phis () )) {
9687
9687
VPReductionPHIRecipe *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
9688
9688
if (!PhiR)
9689
9689
continue ;
9690
9690
9691
+ ScalarEvolution &SE = *PSE.getSE ();
9692
+ auto *PN = cast<PHINode>(PhiR->getUnderlyingValue ());
9693
+ if (auto *C = dyn_cast<SCEVConstant>(SE.getSCEV (PN))) {
9694
+ VPValue *PV = Plan->getOrAddLiveIn (C->getValue ());
9695
+ PhiR->replaceAllUsesWith (PV);
9696
+ PhiR->eraseFromParent ();
9697
+ continue ;
9698
+ }
9691
9699
const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9692
9700
// If tail is folded by masking, introduce selects between the phi
9693
9701
// and the users outside the vector region of each reduction, at the
You can’t perform that action at this time.
0 commit comments