@@ -6003,19 +6003,23 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
6003
6003
if (IncValue == P)
6004
6004
continue ;
6005
6005
6006
+ Instruction *CxtI = P->getIncomingBlock (U)->getTerminator ();
6007
+
6006
6008
// 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
6008
6010
Value *V;
6009
6011
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)))) {
6011
6013
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
+ }
6019
6023
}
6020
6024
6021
6025
KnownFPClass KnownSrc;
@@ -6024,8 +6028,7 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
6024
6028
// detect known sign bits.
6025
6029
computeKnownFPClass (IncValue, DemandedElts, InterestedClasses, KnownSrc,
6026
6030
PhiRecursionLimit,
6027
- Q.getWithoutCondContext ().getWithInstruction (
6028
- P->getIncomingBlock (U)->getTerminator ()));
6031
+ Q.getWithoutCondContext ().getWithInstruction (CxtI));
6029
6032
6030
6033
if (First) {
6031
6034
Known = KnownSrc;
0 commit comments