From: Gerolf Hoflehner Date: Wed, 1 Oct 2014 03:24:39 +0000 (+0000) Subject: [InstCombine] Fix for assert build failures caused by r218721 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3adf585efec9dde093c9df36af1012bbe1bf0506;p=oota-llvm.git [InstCombine] Fix for assert build failures caused by r218721 The icmp-select-icmp optimization made the implicit assumption that the select-icmp instructions are in the same block and asserted on it. The fix explicitly checks for that condition and conservatively suppresses the optimization when it is violated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218735 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index c264e256605..e10eab1f81a 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2442,7 +2442,7 @@ static bool swapMayExposeCSEOpportunities(const Value * Op0, bool InstCombiner::dominatesAllUses(const Instruction *DI, const Instruction *UI, const BasicBlock *DB) const { - assert(DI && DI->getParent() == UI->getParent() && + assert(DI && UI && DI->getParent() == UI->getParent() && "definition and use must be in the same block"); // DominatorTree available? if (!DT) @@ -2468,6 +2468,12 @@ static bool isChainSelectCmpBranch(const SelectInst *SI) { auto *IC = dyn_cast(BI->getCondition()); if (!IC || (IC->getOperand(0) != SI && IC->getOperand(1) != SI)) return false; + // FIXME: Conservatively suppress the optimization when the IC + // has a parent different from SI (including no parent). Otherwise + // the assertion in dominatesAllUses() fires and causes a build failure. + // Make the optimization safe w/o this condition. + if (SI->getParent() != IC->getParent()) + return false; return true; }