Skip to content

Commit 9752839

Browse files
Dinar TemirbulatovDinar Temirbulatov
authored andcommitted
Resolved remarks.
1 parent 53a4a2f commit 9752839

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,11 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
639639
return InstDesc(Select, Prev.getRecKind());
640640
}
641641

642+
// Find the compare instruction that is associated with OrigPhi, i.e
643+
// recurrent-reduction. And determine that SelectInst and CmpInst multiple
644+
// instructions usage are safe to vectorise.
642645
SelectInst *SI = dyn_cast<SelectInst>(I);
643646
Instruction *Cmp = nullptr;
644-
645647
if (SI) {
646648
bool HasOrigPhiUser = false;
647649
bool SelectNonPHIUserInLoop = false;
@@ -653,6 +655,8 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
653655
if (Inst == OrigPhi) {
654656
HasOrigPhiUser = true;
655657
} else {
658+
// If we found SelectInstr usage in the loop then the reduction stops
659+
// to be recurrent and it is not safe to procede further.
656660
if (std::find(Blocks.begin(), Blocks.end(), Inst->getParent()) !=
657661
Blocks.end())
658662
SelectNonPHIUserInLoop = true;
@@ -683,6 +687,8 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
683687
}
684688
if (!IsSafeCMP)
685689
Cmp = nullptr;
690+
} else {
691+
Cmp = nullptr;
686692
}
687693
}
688694

0 commit comments

Comments
 (0)