Index: llvm/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/lib/Analysis/InstructionSimplify.cpp +++ llvm/lib/Analysis/InstructionSimplify.cpp @@ -4095,6 +4095,11 @@ /// See if we can fold the given phi. If not, returns null. static Value *SimplifyPHINode(PHINode *PN, const SimplifyQuery &Q) { + // LCSSA PHIs only have one input value + // return nullptr here to avoid simplifying them away + // since they are necessary to hold out of the loop dependecies. + if (PN->getNumIncomingValues() < 2) + return nullptr; // If all of the PHI's incoming values are the same then replace the PHI node // with the common value. Value *CommonValue = nullptr;