Index: lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- lib/Transforms/Utils/SimplifyCFG.cpp +++ lib/Transforms/Utils/SimplifyCFG.cpp @@ -4720,6 +4720,15 @@ return false; MapCaseToResult(CaseVal, UniqueResults, Results.begin()->second); + // No more than two unique results can be selected between. + if (UniqueResults.size() > 2) + return false; + + // No result may have more than one case that selects it. + for(const auto &RI : UniqueResults) + if (RI.second.size() > 1) + return false; + // Check the PHI consistency. if (!PHI) PHI = Results[0].first;