Skip to content

Commit 556743a

Browse files
committed
Capture LHS and RHS of select instruction by match.
1 parent 4f743ab commit 556743a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,17 +692,18 @@ RecurrenceDescriptor::isFindLastIVPattern(PHINode *OrigPhi, Instruction *I,
692692
ScalarEvolution &SE) {
693693
// TODO: Match selects with multi-use cmp conditions.
694694
CmpInst::Predicate Pred;
695-
if (!match(I, m_Select(m_OneUse(m_Cmp(Pred, m_Value(), m_Value())), m_Value(),
696-
m_Value())))
695+
Value *TrueVal, *FalseVal;
696+
if (!match(I, m_Select(m_OneUse(m_Cmp(Pred, m_Value(), m_Value())),
697+
m_Value(TrueVal), m_Value(FalseVal))))
697698
return InstDesc(false, I);
698699

699700
auto *SI = cast<SelectInst>(I);
700701
Value *NonRdxPhi = nullptr;
701702

702-
if (OrigPhi == dyn_cast<PHINode>(SI->getTrueValue()))
703-
NonRdxPhi = SI->getFalseValue();
704-
else if (OrigPhi == dyn_cast<PHINode>(SI->getFalseValue()))
705-
NonRdxPhi = SI->getTrueValue();
703+
if (OrigPhi == dyn_cast<PHINode>(TrueVal))
704+
NonRdxPhi = FalseVal;
705+
else if (OrigPhi == dyn_cast<PHINode>(FalseVal))
706+
NonRdxPhi = TrueVal;
706707
else
707708
return InstDesc(false, I);
708709

0 commit comments

Comments
 (0)