@@ -849,17 +849,12 @@ RecurrenceDescriptor::isMinMaxPattern(Instruction *I, RecurKind Kind,
849849// / %sum.2 = select %cmp, %add, %sum.1
850850RecurrenceDescriptor::InstDesc
851851RecurrenceDescriptor::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
892887RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr (
0 commit comments