Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -4581,6 +4581,9 @@ Value *CmpRHS = CmpI->getOperand(1); Value *TrueVal = SI->getTrueValue(); Value *FalseVal = SI->getFalseValue(); + assert(SI != TrueVal && SI != FalseVal && + "Trying to match select pattern for select that refers to itself"); + FastMathFlags FMF; if (isa(CmpI)) FMF = CmpI->getFastMathFlags();