Skip to content

Commit ac4374e

Browse files
artagnonakadutta
authored andcommitted
[IVDesc] Improve isConditionalRdxPattern (NFC) (llvm#162818)
1 parent ae9506a commit ac4374e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -849,17 +849,12 @@ RecurrenceDescriptor::isMinMaxPattern(Instruction *I, RecurKind Kind,
849849
/// %sum.2 = select %cmp, %add, %sum.1
850850
RecurrenceDescriptor::InstDesc
851851
RecurrenceDescriptor::isConditionalRdxPattern(Instruction *I) {
852-
SelectInst *SI = dyn_cast<SelectInst>(I);
853-
if (!SI)
854-
return InstDesc(false, I);
855-
856-
CmpInst *CI = dyn_cast<CmpInst>(SI->getCondition());
852+
Value *TrueVal, *FalseVal;
857853
// Only handle single use cases for now.
858-
if (!CI || !CI->hasOneUse())
854+
if (!match(I,
855+
m_Select(m_OneUse(m_Cmp()), m_Value(TrueVal), m_Value(FalseVal))))
859856
return InstDesc(false, I);
860857

861-
Value *TrueVal = SI->getTrueValue();
862-
Value *FalseVal = SI->getFalseValue();
863858
// Handle only when either of operands of select instruction is a PHI
864859
// node for now.
865860
if ((isa<PHINode>(TrueVal) && isa<PHINode>(FalseVal)) ||
@@ -886,7 +881,7 @@ RecurrenceDescriptor::isConditionalRdxPattern(Instruction *I) {
886881
if (!IPhi || IPhi != FalseVal)
887882
return InstDesc(false, I);
888883

889-
return InstDesc(true, SI);
884+
return InstDesc(true, I);
890885
}
891886

892887
RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(

0 commit comments

Comments
 (0)