diff options
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index c264e256605..e10eab1f81a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/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<ICmpInst>(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; } |