Skip to content

Commit 5210091

Browse files
committed
Add a CxtI and restructure code into a loop
1 parent 5b03d62 commit 5210091

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6003,19 +6003,23 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
60036003
if (IncValue == P)
60046004
continue;
60056005

6006+
Instruction *CxtI = P->getIncomingBlock(U)->getTerminator();
6007+
60066008
// If the Use is a select of this phi, use the fp class of the other
6007-
// operand to break the recursion.
6009+
// operand to break the recursion. Same around 2-operand phi nodes
60086010
Value *V;
60096011
if (match(IncValue, m_Select(m_Value(), m_Specific(P), m_Value(V))) ||
6010-
match(IncValue, m_Select(m_Value(), m_Value(V), m_Specific(P))))
6012+
match(IncValue, m_Select(m_Value(), m_Value(V), m_Specific(P)))) {
60116013
IncValue = V;
6012-
// Same around 2-operand phi nodes
6013-
if (auto *IncPhi = dyn_cast<PHINode>(IncValue);
6014-
IncPhi && IncPhi->getNumIncomingValues() == 2) {
6015-
if (IncPhi->getIncomingValue(0) == P)
6016-
IncValue = IncPhi->getIncomingValue(1);
6017-
if (IncPhi->getIncomingValue(1) == P)
6018-
IncValue = IncPhi->getIncomingValue(0);
6014+
} else if (auto *IncPhi = dyn_cast<PHINode>(IncValue);
6015+
IncPhi && IncPhi->getNumIncomingValues() == 2) {
6016+
for (int Idx = 0; Idx < 2; ++Idx) {
6017+
if (IncPhi->getIncomingValue(Idx) == P) {
6018+
IncValue = IncPhi->getIncomingValue(1 - Idx);
6019+
CxtI = IncPhi->getIncomingBlock(1 - Idx)->getTerminator();
6020+
break;
6021+
}
6022+
}
60196023
}
60206024

60216025
KnownFPClass KnownSrc;
@@ -6024,8 +6028,7 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
60246028
// detect known sign bits.
60256029
computeKnownFPClass(IncValue, DemandedElts, InterestedClasses, KnownSrc,
60266030
PhiRecursionLimit,
6027-
Q.getWithoutCondContext().getWithInstruction(
6028-
P->getIncomingBlock(U)->getTerminator()));
6031+
Q.getWithoutCondContext().getWithInstruction(CxtI));
60296032

60306033
if (First) {
60316034
Known = KnownSrc;

0 commit comments

Comments
 (0)